mirror of https://github.com/tiangolo/fastapi.git
15 lines
327 B
Python
15 lines
327 B
Python
from fastapi import FastAPI, Path
|
|
from typing_extensions import Annotated
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
@app.get("/items/{item_id}")
|
|
async def read_items(
|
|
item_id: Annotated[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
|