[FastAPI-02]动态静态路由
from fastapi import FastAPI
app= FastAPI()
# 静态路由模式
@app.get("/login")
def login():
return {"msg":"Welcome CoCo Login"}
@app.get("/books/{number}")
# number:int 类型必须为int 否则会报错
def books(number:int):
return {"msg":{"BookNumber":number,"Price":20}}
http://10.105.212.1:8000/books/100
{
"msg": {
"BookNumber": 100,
"Price": 20
}
}