fastapi 路由管理

定义包并编写路由
# routers\zlmedia_hook.py

from fastapi import APIRouter

router = APIRouter(prefix="/zlmedia/hook", tags=["zlmedia_hook"])

@router.get("/")
async def hello():
 return {"code": "0", "message": "success", "data": "hello world"}

自动加载路由

# main.py

import routers.zlmedia_hook as zlmedia_hook

# 附件路由
app.include_router(zlmedia_hook.router)

