[FastAPI-03]动态静态路由顺序的问题-静态路由先执行

from fastapi import FastAPI

app= FastAPI()

# 静态路由优先级高于动态路由
# 必须写在动态路由的前面
@app.get("/books/most_populer")
def books_most_populer():
    return {"This Book is:":"Python3"}

@app.get("/books/{number}")
def books(number:int):
    return {"msg":{"BookNumber":number,"Price":20}}
posted @ 2023-03-21 16:42  LeoShi2020  阅读(125)  评论(0编辑  收藏  举报