学生信息管理系统
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
from api import statistics
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from api import Score
|
||||
from api import employment_api # 导入 employment_api 子路由
|
||||
from api import teachers
|
||||
from api.advisors import router as advisor_router
|
||||
from api.c_lass import router as class_router
|
||||
from api.students import router as student_router
|
||||
# 从刚才创建的 database.py 中导入 Base 和 engine
|
||||
from database import Base, engine
|
||||
|
||||
# 现在这行代码就不会报错了
|
||||
Base.metadata.create_all(bind=engine)
|
||||
|
||||
|
||||
# 创建 FastAPI 实例
|
||||
app = FastAPI(
|
||||
title="FastAPI + SQLAlchemy 分层架构",
|
||||
description="学生信息管理系统 - 班级模块",
|
||||
version="1.0.0",
|
||||
)
|
||||
|
||||
# 注册班级路由,统一加前缀 /c_lass
|
||||
app.include_router(class_router, prefix="/c_lass", tags=["班级信息管理模块"])
|
||||
# ⑫ 把班级路由注册进应用,统一加前缀 /c_lass
|
||||
# 所以API层里 @router.post("/add") 的完整地址是 POST /c_lass/add
|
||||
app.include_router(employment_api.router, prefix="/api/employment_api", tags=["就业模块管理"])
|
||||
app.include_router(Score.app_score, prefix="/api/score", tags=["成绩管理"])
|
||||
app.include_router(student_router,prefix="/api/student", tags=["学生信息管理"])
|
||||
app.include_router(advisor_router, prefix="/advisors", tags=["顾问老师模块"])
|
||||
app.include_router(teachers.router, prefix="/api/teachers", tags=["老师模块管理"])
|
||||
app.include_router(statistics.router,prefix="/api/statistics",tags=["统计模块"])
|
||||
# 根路径
|
||||
# @app.get("/")
|
||||
# async def root():
|
||||
# return {"message": "欢迎访问!请访问 /docs 查看接口文档。"}
|
||||
|
||||
|
||||
# 直接运行此文件时启动 uvicorn
|
||||
if __name__ == "__main__":
|
||||
import uvicorn
|
||||
uvicorn.run(
|
||||
"main:app",
|
||||
host="127.0.0.1", # 改成本机地址
|
||||
port=8004,
|
||||
reload=True,
|
||||
)
|
||||
Reference in New Issue
Block a user