CIOAgent / main.py
bhuvighosh3
Deployment with restored Stress Specialist data
9fbb3f2
Raw History Blame Contribute Delete
1.94 kB
from fastapi import FastAPI, Response
from fastapi.middleware.cors import CORSMiddleware
from fastapi.staticfiles import StaticFiles
import os
from api.routes_agents import router as agents_router
from api.routes_analysis import router as analysis_router
from api.routes_auth import router as auth_router
from api.routes_tts import router as tts_router
from api.routes_tts import router as tts_router
from api.routes_user_data import router as user_data_router
from api.routes_alerts import router as alerts_router
from api.routes_insights import router as insights_router
from api.routes_portfolio_versions import router as portfolio_versions_router
from api.routes_reports import router as reports_router
app = FastAPI(title="Portfolio CIO", version="1.0.0")
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(auth_router)
app.include_router(user_data_router)
app.include_router(analysis_router)
app.include_router(agents_router)
app.include_router(agents_router)
app.include_router(tts_router)
app.include_router(alerts_router)
app.include_router(insights_router)
app.include_router(portfolio_versions_router)
app.include_router(reports_router)
# Serve static files from the frontend/dist directory
if os.path.exists("frontend/dist"):
app.mount("/", StaticFiles(directory="frontend/dist", html=True), name="static")
@app.get("/{full_path:path}")
async def serve_frontend(full_path: str):
if os.path.exists(os.path.join("frontend/dist", full_path)):
return Response(status_code=200)
if os.path.exists("frontend/dist/index.html"):
with open("frontend/dist/index.html", "r") as f:
return Response(content=f.read(), media_type="text/html")
return {"message": "Frontend not found. Please build the frontend."}
@app.get("/health")
async def health():
return {"status": "ok"}