关键方法:

参数: 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)

结果截图:
结果截图

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐