Files
2026-09-21 21:02:30 +08:00

35 lines
2.1 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ============================================================
# main.py —— 系统启动入口
# 职责:创建 FastAPI 应用、注册各业务模块的路由,并启动服务
# ============================================================
import uvicorn # ASGI 服务器,用于运行 FastAPI 应用
from fastapi import FastAPI
# 导入各业务模块的路由器(api 包下每个文件对应一个业务模块)
from api import student_api,employment_api,advisor_api,teacher_api,score_api,classinfo_api,api_analysis
# 创建 FastAPI 应用实例;title 会显示在 Swagger 接口文档中
app = FastAPI(title="沃林学生管理系统", version="1.0.0")
# 注册学生模块路由:所有接口挂载在 /students 前缀下
app.include_router(student_api.router, prefix="/students", tags=["学生模块"])
# 注册就业模块路由:所有接口挂载在 /employment 前缀下
app.include_router(employment_api.router,prefix="/employment",tags=["就业模块"])
# 注册顾问模块路由:所有接口挂载在 /advisor 前缀下
app.include_router(advisor_api.router,prefix="/advisor",tags=["顾问模块"])
# 注册教师模块路由:所有接口挂载在 /teacher 前缀下
app.include_router(teacher_api.router,prefix="/teacher",tags=["教师模块"])
# 注册成绩模块路由:所有接口挂载在 /score 前缀下
app.include_router(score_api.router,prefix="/score",tags=["成绩模块"])
# 注册班级模块路由:所有接口挂载在 /classinfo 前缀下
app.include_router(classinfo_api.router,prefix="/classinfo",tags=["班级模块"])
# 注册统计分析模块路由:所有接口挂载在 /analysis 前缀下
app.include_router(api_analysis.router,prefix="/analysis",tags=["统计分析模块"])
# 仅在直接运行本文件时执行(python main.py)
if __name__=="__main__":
# 如需在启动时自动建表,可取消下行注释(需要提前建好数据库)
# Base.metadata.create_all(bind=engine)
# 启动开发服务器:监听 localhost:8051,reload=True 开启代码热重载
uvicorn.run("main:app",host="localhost",port=8051,reload=True)