初次提交
This commit is contained in:
79
backend/simple_main.py
Normal file
79
backend/simple_main.py
Normal file
@@ -0,0 +1,79 @@
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
import time
|
||||
|
||||
app = FastAPI(
|
||||
title="云盘应用 API",
|
||||
description="现代化的云存储Web应用后端API",
|
||||
version="1.0.0",
|
||||
docs_url="/docs",
|
||||
redoc_url="/redoc"
|
||||
)
|
||||
|
||||
# CORS中间件
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["http://localhost:3000", "http://127.0.0.1:3000"],
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
@app.get("/")
|
||||
async def root():
|
||||
return {"message": "云盘应用 API", "version": "1.0.0"}
|
||||
|
||||
@app.get("/api/v1/health")
|
||||
async def health_check():
|
||||
"""基础健康检查"""
|
||||
return {
|
||||
"success": True,
|
||||
"data": {
|
||||
"status": "healthy",
|
||||
"service": "cloud-drive-api",
|
||||
"environment": "development",
|
||||
"timestamp": int(time.time())
|
||||
},
|
||||
"message": "API服务运行正常"
|
||||
}
|
||||
|
||||
@app.get("/api/v1/ready")
|
||||
async def readiness_check():
|
||||
"""就绪检查 - 简化版本,不检查数据库"""
|
||||
checks = {
|
||||
"api": {
|
||||
"status": "healthy",
|
||||
"message": "API服务正常"
|
||||
},
|
||||
"database": {
|
||||
"status": "unknown",
|
||||
"message": "数据库连接未配置(简化模式)"
|
||||
},
|
||||
"redis": {
|
||||
"status": "unknown",
|
||||
"message": "Redis连接未配置(简化模式)"
|
||||
},
|
||||
"storage": {
|
||||
"status": "healthy",
|
||||
"message": "文件存储正常"
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
"success": True,
|
||||
"data": {
|
||||
"status": "ready",
|
||||
"checks": checks,
|
||||
"timestamp": int(time.time())
|
||||
},
|
||||
"message": "API服务已就绪(简化模式)"
|
||||
}
|
||||
|
||||
if __name__ == "__main__":
|
||||
import uvicorn
|
||||
uvicorn.run(
|
||||
"simple_main:app",
|
||||
host="0.0.0.0",
|
||||
port=8000,
|
||||
reload=True
|
||||
)
|
||||
Reference in New Issue
Block a user