mirror of
https://github.com/fastapi/fastapi.git
synced 2026-02-26 11:46:43 -05:00
📝 Add first tutorial src files
This commit is contained in:
15
docs/tutorial/src/tutorial16.py
Normal file
15
docs/tutorial/src/tutorial16.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from fastapi import FastAPI, Query
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
@app.get("/items/")
|
||||
async def read_items(
|
||||
q: str = Query(
|
||||
None, title="Query string", min_length=3, max_length=50, regex="^fixedquery$"
|
||||
)
|
||||
):
|
||||
results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
|
||||
if q:
|
||||
results.update({"q": q})
|
||||
return results
|
||||
Reference in New Issue
Block a user