| 1 |
from typing import Annotated |
| 2 |
|
| 3 |
from fastapi import FastAPI, Query |
| 4 |
|
| 5 |
app = FastAPI() |
| 6 |
|
| 7 |
|
| 8 |
@app.get("/items/") |
| 9 |
async def read_items(q: Annotated[str, Query(min_length=3)]): |
| 10 |
results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]} |
| 11 |
if q: |
| 12 |
results.update({"q": q}) |
| 13 |
return results |