首页 > 其他分享 >[FastAPI-06]路径转换器

[FastAPI-06]路径转换器

时间:2023-03-23 10:24:04浏览次数:47  
标签:06 FastAPI app 路径 number 转换器 path

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}}

标签:06,FastAPI,app,路径,number,转换器,path
From: https://www.cnblogs.com/leoshi/p/17246490.html

相关文章