修改main文件

新增统计api
新增统计请求模型
This commit is contained in:
jianqi
2026-09-12 14:32:31 +08:00
parent 5078d4d0c9
commit e7175958c7
3 changed files with 43 additions and 1 deletions
+3 -1
View File
@@ -5,7 +5,7 @@ from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from database import engine, Base
from api1 import users # 导入 users 子路由
from api1 import users, statistics_api # 导入 users 子路由
# 1. 创建数据库表(如果表不存在)
# Base.metadata.create_all 会扫描所有继承 Base 的模型,生成对应的 CREATE TABLE 语句
@@ -32,6 +32,8 @@ app.add_middleware(
# prefix 为路由前缀,所有用户接口都以 /api/users 开头
app.include_router(users.router, prefix="/api/users", tags=["用户管理"])
app.include_router(statistics_api.router, prefix="/api/stats", tags=["统计分析"])
# 5. 根路径
@app.get("/")
async def root():