25 lines
624 B
Python
25 lines
624 B
Python
from contextlib import asynccontextmanager
|
|
from fastapi import FastAPI
|
|
from fastapi.staticfiles import StaticFiles
|
|
from pathlib import Path
|
|
from app.database import init_db
|
|
from app.routes import webhook, api, pages
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
await init_db()
|
|
yield
|
|
|
|
|
|
app = FastAPI(title="微信客服 API 测试工具", lifespan=lifespan)
|
|
|
|
# 静态文件
|
|
static_dir = Path(__file__).parent / "static"
|
|
app.mount("/static", StaticFiles(directory=str(static_dir)), name="static")
|
|
|
|
# 路由
|
|
app.include_router(pages.router)
|
|
app.include_router(webhook.router)
|
|
app.include_router(api.router)
|