| 1 |
from fastapi import FastAPI, Path |
| 2 |
|
| 3 |
app = FastAPI() |
| 4 |
|
| 5 |
|
| 6 |
@app.get("/items/{item_id}") |
| 7 |
async def read_items( |
| 8 |
*, |
| 9 |
item_id: int = Path(title="The ID of the item to get", gt=0, le=1000), |
| 10 |
q: str, |
| 11 |
): |
| 12 |
results = {"item_id": item_id} |
| 13 |
if q: |
| 14 |
results.update({"q": q}) |
| 15 |
return results |