26 lines
812 B
Python
26 lines
812 B
Python
from fastapi import FastAPI
|
|
from database import engine, Base
|
|
Base.metadata.create_all(engine)
|
|
from api.calss import class_api
|
|
from api.employment_api import app as employment_router
|
|
from starlette.middleware.cors import CORSMiddleware
|
|
|
|
|
|
app = FastAPI()
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"], # 允许所有源(生产环境建议指定具体域名)
|
|
allow_credentials=True, # 允许携带 Cookie 等凭证
|
|
allow_methods=["*"], # 允许所有 HTTP 方法(GET/POST/PUT/DELETE 等)
|
|
allow_headers=["*"], # 允许所有请求头
|
|
)
|
|
|
|
app.include_router(class_api,tags=['班级接口'],prefix='/stutent')
|
|
app.include_router(employment_router)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
import uvicorn
|
|
|
|
uvicorn.run("main:app", host='127.0.0.1', port=12345) |