mirror of
https://github.com/fastapi/fastapi.git
synced 2026-04-04 15:13:26 -04:00
14 lines
285 B
Python
14 lines
285 B
Python
from fastapi import FastAPI, Path
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
@app.get("/items/{item_id}")
|
|
async def read_items(
|
|
*, item_id: int = Path(..., title="The ID of the item to get", ge=1), q: str
|
|
):
|
|
results = {"item_id": item_id}
|
|
if q:
|
|
results.update({"q": q})
|
|
return results
|