Spaces:
Sleeping
Sleeping
Download backend/app/main.py from ApyHTML19/PaperBrainAI: direct link, hf CLI and curl.
- Browser
- Download file 971 Bytes
-
https://huggingface.co/spaces/ApyHTML19/PaperBrainAI/resolve/main/backend/app/main.py
- Command line
-
hf download hf://spaces/ApyHTML19/PaperBrainAI/backend/app/main.py
-
curl -L -o main.py https://huggingface.co/spaces/ApyHTML19/PaperBrainAI/resolve/main/backend/app/main.py
971 Bytes
| from fastapi import FastAPI | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from fastapi.staticfiles import StaticFiles | |
| from fastapi.responses import FileResponse | |
| from app.router_service import router | |
| from app.db.database import create_tables | |
| import os | |
| app = FastAPI( | |
| title="PaperBrain API BY HICHAM", | |
| description="API d'assistance à l'apprentissage avec auth et profils", | |
| ) | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins=["*"], | |
| allow_methods=["*"], | |
| allow_headers=["*"], | |
| ) | |
| def startup(): | |
| create_tables() | |
| print("Tables créées avec succès") | |
| app.include_router(router, prefix="/api") | |
| def health(): | |
| return {"status": "ok"} | |
| # Servir le frontend React — DOIT être en dernier | |
| if os.path.exists("static"): | |
| app.mount("/", StaticFiles(directory="static", html=True), name="static") | |
| else: | |
| def root(): | |
| return {"message": "SmartStudyAI v2.0 running"} |