| 123456789101112131415161718192021222324252627282930 |
- # app/main.py
- from fastapi import FastAPI
- from fastapi.middleware.cors import CORSMiddleware
- from app.core.config import settings
- from app.api.endpoints import router
- app = FastAPI(
- title=settings.PROJECT_NAME,
- openapi_url=f"{settings.API_V1_STR}/openapi.json"
- )
- # CORS 配置
- app.add_middleware(
- CORSMiddleware,
- allow_origins=["*"], # 生产环境建议改为具体的 ["http://localhost:8080"]
- allow_credentials=True,
- allow_methods=["*"],
- allow_headers=["*"],
- )
- # 注册路由
- app.include_router(router, prefix=settings.API_V1_STR) # 前缀 /api
- @app.get("/")
- async def root():
- return {"message": "MinIO FileManager Backend is Running"}
- if __name__ == "__main__":
- import uvicorn
- uvicorn.run("app.main:app", host="0.0.0.0", port=8080, reload=True)
|