feat:添加前端页面
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#项目初始化入口
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
# 周学灵、熊浩钦、圣国伟、刘盼、彭少、赵康宁的路由
|
||||
from api import wl_student_api,wl_class_api,wl_score_api,wl_teacher_api,statistics,wl_emp_api,wl_advisor_api
|
||||
from database import Base, engine
|
||||
@@ -11,6 +12,18 @@ Base.metadata.drop_all(engine)
|
||||
Base.metadata.create_all(bind=engine)
|
||||
|
||||
app = FastAPI(title="沃林学生管理系统")
|
||||
|
||||
# 前端页面单独起一个静态服务器(在 static 目录里执行 python -m http.server 8080),
|
||||
# 和后端不同源,所以由后端放行跨域请求。这里不挂载静态文件。
|
||||
# 注意:allow_origins=["*"] 不能和 allow_credentials=True 同时用,浏览器会直接拒绝;
|
||||
# 本项目接口没有登录态、不需要带 cookie,所以可以放心用 "*"。
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"],
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
app.include_router(wl_student_api.router)
|
||||
app.include_router(wl_class_api.router)
|
||||
app.include_router(wl_score_api.router)
|
||||
|
||||
Reference in New Issue
Block a user