FastAPI url查询参数
url:
http://127.0.0.1:8000/items/?skip=0&limit=10
http://127.0.0.1:8000/items/?skip=20
route:
from fastapi import FastAPI
app = FastAPI()
fake_items_db = [{"item_name": "Foo"}, {"item_name": "Bar"}, {"item_name": "Baz"}]
@app.get("/items/")
#默认值 skip = 0 limit = 10
async def read_item(skip: int = 0, limit: int = 10):
return fake_items_db[skip : skip + limit]