2022年4月27日
摘要: 声明的参数不是路径参数时,路径操作函数会把该参数自动解释为查询参数。 from fastapi import FastAPI app = FastAPI() fake_items_db = [{"item_name": "foo"}, {"item_name": "bar"}, {"item_nam 阅读全文
posted @ 2022-04-27 20:18 司徒轩宇 阅读(256) 评论(0) 推荐(0) 编辑
摘要: FastAPI 使用python 字符串格式化语法声明路径参数(变量)。 from fastapi import FastAPI app = FastAPI() @app.get("/items/{item_id}") async def read_item(item_id): return {"i 阅读全文
posted @ 2022-04-27 17:06 司徒轩宇 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 第一步:导入FastAPI from fastapi import FastAPI #导入FastAPI app = FastAPI() @app.get("/") async def root(): return {"message": "Hello World"} FastAPI是继承了Star 阅读全文
posted @ 2022-04-27 16:03 司徒轩宇 阅读(200) 评论(0) 推荐(0) 编辑