mirror of
https://github.com/fastapi/fastapi.git
synced 2025-12-29 01:00:51 -05:00
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
17 lines
345 B
Python
17 lines
345 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", ge=0, le=1000),
|
|
q: str,
|
|
size: float = Query(gt=0, lt=10.5),
|
|
):
|
|
results = {"item_id": item_id}
|
|
if q:
|
|
results.update({"q": q})
|
|
return results
|