[FastAPI-10]查询参数多个相同的值

from fastapi import FastAPI, Query
import typing

app = FastAPI()

'''
查询多个参数值相同
'''

@app.get("/books")
def books(book_id: typing.List[int] = Query()):
    return {"id": book_id}

http://10.105.212.1:8000/books?book_id=1&book_id=20

{
  "id": [
    1,
    20
  ]
}
posted @ 2023-03-23 20:36  LeoShi2020  阅读(46)  评论(0)    收藏  举报