from fastapi import FastAPI,Path
app = FastAPI()
# Path校验
'''
限制接口输入的数字大小限制 100-1000
限制字符串输入的字符数量 3-8位
'''
@app.get("/number/{num}")
def number(num:int = Path(ge=100,le=1000)):
return {"number":num}
@app.get("/word/{name}")
def word(name:str = Path(min_length=3,max_length=8)):
return {"word":name}
标签:word,FastAPI,08,number,num,Path,app
From: https://www.cnblogs.com/leoshi/p/17248013.html