File size: 1,941 Bytes
9fbb3f2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 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"}
|