mirror of
https://github.com/fastapi/fastapi.git
synced 2026-11-21 02:03:39 +08:00
16 lines
311 B
Python
16 lines
311 B
Python
from typing import Annotated
|
|
|
|
from fastapi import FastAPI, Path
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
@app.get("/items/{item_id}")
|
|
async def read_items(
|
|
item_id: Annotated[int, Path(title="The ID of the item to get")], q: str
|
|
):
|
|
results = {"item_id": item_id}
|
|
if q:
|
|
results.update({"q": q})
|
|
return results
|