Spaces:
Sleeping
Sleeping
Download backend/main.py from hamba-ho/Assistant-Web-Educatif: direct link, hf CLI and curl.
- Browser
- Download file 1.23 kB
-
https://huggingface.co/spaces/hamba-ho/Assistant-Web-Educatif/resolve/main/backend/main.py
- Command line
-
hf download hf://spaces/hamba-ho/Assistant-Web-Educatif/backend/main.py
-
curl -L -o main.py https://huggingface.co/spaces/hamba-ho/Assistant-Web-Educatif/resolve/main/backend/main.py
1.23 kB
| # backend/main.py | |
| from fastapi import FastAPI | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from fastapi.staticfiles import StaticFiles | |
| from api.routes import questions, documents | |
| from config.settings import settings | |
| from config.database import Base, engine | |
| import models.interaction | |
| import models.session_config | |
| import os | |
| # Crée automatiquement toutes les tables SQLite au démarrage | |
| Base.metadata.create_all(bind=engine) | |
| app = FastAPI( | |
| title=settings.PROJECT_NAME, | |
| description="API pour l'assistant éducatif RAG.", | |
| version="1.0.0" | |
| ) | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins=["*"], | |
| allow_credentials=True, | |
| allow_methods=["*"], | |
| allow_headers=["*"], | |
| ) | |
| app.include_router(questions.router, prefix="/api/v1", tags=["Questions RAG"]) | |
| app.include_router(documents.router, prefix="/api/v1", tags=["Documents"]) | |
| # Servir le frontend statique si présent | |
| frontend_dist = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "frontend") | |
| if os.path.exists(frontend_dist): | |
| app.mount("/", StaticFiles(directory=frontend_dist, html=True), name="frontend") | |
| def health_check(): | |
| return {"status": "ok", "project": settings.PROJECT_NAME} |