03-查询参数
from fastapi import FastAPI, Query
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello World"}
# 需求 查询新闻 → 分页,skip: 跳过的记录数, limit:返回的记录数 10
@app.get("/news/news_list")
async def get_news_list(
skip: int = Query(0, description="跳过的记录数", lt=100),
limit: int = Query(10, description="返回的记录数")
):
return {"skip": skip, "limit": limit}

浙公网安备 33010602011771号