from fastapi import FastAPI from typing import Optional import uvicorn app = FastAPI() # 必传参数+可选参数 @app.get("/items") async def read_item(item_id: str, name: Optional[str] = None): return {"item_id": item_id, "name": name} if __name__ == "__main__": uvicorn.run(app="4_get_valiation:app", host="127.0.0.1", port=8080, debug=True, reload=True)
FastAPI(6)- get 请求 - 详解 Query
内容版权声明:除非注明,否则皆为本站原创文章。