mirror of
https://github.com/rjNemo/fastapi
synced 2026-06-06 10:36:39 +00:00
14 lines
329 B
Python
14 lines
329 B
Python
from fastapi import FastAPI, Path, Query
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
@app.get("/items/{item_id}")
|
|
async def read_items(
|
|
item_id: int = Path(..., title="The ID of the item to get"),
|
|
q: str | None = Query(None, alias="item-query"),
|
|
):
|
|
results = {"item_id": item_id}
|
|
if q:
|
|
results.update({"q": q})
|
|
return results
|