后端开发完成
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from app.config import settings
|
||||
from app.api import auth, user, project
|
||||
|
||||
# 创建FastAPI应用实例
|
||||
app = FastAPI(
|
||||
title=settings.app_name,
|
||||
description="项目管理系统后端API",
|
||||
version="0.1.0"
|
||||
)
|
||||
|
||||
# 配置CORS
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"], # 在生产环境中应该设置具体的前端域名
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
# 注册路由
|
||||
app.include_router(auth.router, prefix="/api")
|
||||
app.include_router(user.router, prefix="/api")
|
||||
app.include_router(project.router, prefix="/api")
|
||||
|
||||
|
||||
@app.get("/")
|
||||
def read_root():
|
||||
"""根路径"""
|
||||
return {
|
||||
"message": "Welcome to Project Management API",
|
||||
"version": "0.1.0",
|
||||
"docs": "/docs"
|
||||
}
|
||||
|
||||
|
||||
@app.get("/health")
|
||||
def health_check():
|
||||
"""健康检查"""
|
||||
return {"status": "healthy"}
|
||||
Reference in New Issue
Block a user