fastapi实现同参数多值请求
关键方法:参数: List[str] = Query(...)实例代码:from typing import Listimport uvicornfrom fastapi import Query, FastAPIapp = FastAPI()@app.get("/api")async def get_item(id: List[str] = Query(...)):return {'id': i
·
关键方法:
参数: List[str] = Query(...)
实例代码:
from typing import List
import uvicorn
from fastapi import Query, FastAPI
app = FastAPI()
@app.get("/api")
async def get_item(id: List[str] = Query(...)):
return {'data': id}
if __name__ == '__main__':
uvicorn.run("demo:app", host="127.0.0.1", port=9527)
结果截图:
更多推荐
已为社区贡献1条内容
所有评论(0)