fastapi-master/docs_src/query_params/tutorial001.py

11 lines
250 B
Python
Raw Normal View History

2024-08-24 12:41:47 +08:00
from fastapi import FastAPI
app = FastAPI()
fake_items_db = [{"item_name": "Foo"}, {"item_name": "Bar"}, {"item_name": "Baz"}]
@app.get("/items/")
async def read_item(skip: int = 0, limit: int = 10):
return fake_items_db[skip : skip + limit]