from fastapi import FastAPI
app= FastAPI()
# 路径转换器
'''
- str 字符串
- int 数字
- float 浮点
- uuid 返回python中的uuid.UUID
- path 文件路径包含多个/
'''
@app.get("/books/{number:int}")
def books(number):
print(type(number))
return {"msg":{"BookNumber":number,"Price":20}}
# /opt/data/my.cnf
@app.get("/files/{path:path}")
def upload_files(path):
return {"msg":{"file_path":path}}
[FastAPI-06]路径转换器
发布时间 2023-03-23 10:18:05作者: LeoShi2020