FastAPI系列:路由配置多个http请求方法
一个路由配置多个http请求方法
app = FastAPI(routes=None)
# 方式一:app.api_route()
@app.api_route(path='/index', methods=['GET','POST'])
async def index():
return {'msg':"index"}
# 方式二:app.add_api_route()
app = FastAPI(routes=None)
async def index():
return JSONResponse({'msg':"index"})
app.add_api_route(path='/index', endpoint='index', methods=['GET','POST'])
-------------------------------------------
个性签名:代码过万,键盘敲烂!!!
如果觉得这篇文章对你有小小的帮助的话,记得在右下角点个“推荐”哦,博主在此感谢!