[FastAPI-16]Body参数校验

from fastapi import FastAPI,Body

app =FastAPI()


'''
使用方法同Path Query
'''
@app.post("/login")
def login(
        name :str = Body(min_length=3),
        age:int = Body(ge=18)
):
    return {
        "name":name,
        "age":age
    }
posted @ 2023-03-24 00:17  LeoShi2020  阅读(54)  评论(0编辑  收藏  举报