Aasher/Flexx_Your_Homework_Assistant
0
1from fastapi import FastAPI, HTTPException2from fastapi.staticfiles import StaticFiles3from fastapi.responses import FileResponse4from fastapi.middleware.cors import CORSMiddleware5from dotenv import load_dotenv6 7from api.chat import chat_router8 9load_dotenv()10 11app = FastAPI(12 title="Chat Assistant API",13 description="FastAPI backend for chat assistant with LiteLLM and Gemini",14 version="1.0.0"15)16 17# CORS middleware for frontend integration18app.add_middleware(19 CORSMiddleware,20 allow_origins=["*"], # Configure this properly for production21 allow_credentials=True,22 allow_methods=["*"],23 allow_headers=["*"],24)25 26# Include routers27app.include_router(chat_router, prefix="/api")28 29# Mount static files for the frontend30app.mount("/static", StaticFiles(directory="static"), name="static")31 32@app.get("/")33async def root():34 return FileResponse("static/index.html")35 36@app.get("/health")37async def health_check():38 return {"status": "healthy"}