Spaces:
Sleeping
Sleeping
| """ | |
| Application FastAPI principale | |
| """ | |
| from fastapi import FastAPI | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from fastapi.responses import HTMLResponse | |
| from app.routers import admission, rh | |
| from app.core.config import settings | |
| # Configuration de l'application | |
| app = FastAPI( | |
| title="API Admission Rush School", | |
| description="API pour gérer les documents d'admission et le module RH", | |
| version="1.0.0", | |
| debug=settings.debug | |
| ) | |
| # Configuration CORS | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins=["http://localhost:3000", "http://localhost:5173", "*"], # À restreindre en production | |
| allow_credentials=True, | |
| allow_methods=["*"], | |
| allow_headers=["*"], | |
| ) | |
| # Inclure les routers | |
| app.include_router(admission.router, prefix="/api/v1") | |
| app.include_router(rh.router, prefix="/api/v1") | |
| async def root(): | |
| """Page d'accueil de l'API""" | |
| return """ | |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>API Admission Rush School</title> | |
| <style> | |
| body { font-family: Arial, sans-serif; margin: 40px; } | |
| .container { max-width: 800px; margin: 0 auto; } | |
| .header { text-align: center; margin-bottom: 30px; } | |
| .endpoint { background: #f5f5f5; padding: 15px; margin: 10px 0; border-radius: 5px; } | |
| .method { font-weight: bold; color: #2196F3; } | |
| .path { font-family: monospace; background: #e8e8e8; padding: 2px 6px; border-radius: 3px; } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="container"> | |
| <div class="header"> | |
| <h1>🎓 API Admission Rush School</h1> | |
| <p>API pour gérer les documents d'admission des candidats</p> | |
| </div> | |
| <h2>📋 Endpoints disponibles</h2> | |
| <div class="endpoint"> | |
| <span class="method">GET</span> <span class="path">/api/v1/admission/candidates</span><br> | |
| Récupère tous les candidats | |
| </div> | |
| <div class="endpoint"> | |
| <span class="method">GET</span> <span class="path">/api/v1/admission/candidates/{record_id}/documents</span><br> | |
| Récupère le statut des documents d'un candidat | |
| </div> | |
| <div class="endpoint"> | |
| <span class="method">POST</span> <span class="path">/api/v1/admission/candidates/{record_id}/documents/cv</span><br> | |
| Upload d'un CV | |
| </div> | |
| <div class="endpoint"> | |
| <span class="method">POST</span> <span class="path">/api/v1/admission/candidates/{record_id}/documents/cin</span><br> | |
| Upload d'une carte d'identité | |
| </div> | |
| <div class="endpoint"> | |
| <span class="method">POST</span> <span class="path">/api/v1/admission/candidates/{record_id}/documents/lettre-motivation</span><br> | |
| Upload d'une lettre de motivation | |
| </div> | |
| <div class="endpoint"> | |
| <span class="method">POST</span> <span class="path">/api/v1/admission/candidates/{record_id}/documents/carte-vitale</span><br> | |
| Upload d'une carte vitale | |
| </div> | |
| <div class="endpoint"> | |
| <span class="method">POST</span> <span class="path">/api/v1/admission/candidates/{record_id}/documents/dernier-diplome</span><br> | |
| Upload d'un dernier diplôme | |
| </div> | |
| <div class="endpoint"> | |
| <span class="method">GET</span> <span class="path">/api/v1/admission/health</span><br> | |
| Vérification de santé de l'API | |
| </div> | |
| <h2>📚 Documentation</h2> | |
| <p> | |
| <a href="/docs" target="_blank">📖 Documentation Swagger UI</a><br> | |
| <a href="/redoc" target="_blank">📘 Documentation ReDoc</a> | |
| </p> | |
| <h2>ℹ️ Informations</h2> | |
| <ul> | |
| <li><strong>Taille maximum des fichiers:</strong> 10 MB</li> | |
| <li><strong>Formats autorisés:</strong> PDF, DOC, DOCX, JPG, JPEG, PNG</li> | |
| <li><strong>Base de données:</strong> Airtable</li> | |
| </ul> | |
| </div> | |
| </body> | |
| </html> | |
| """ | |
| async def health(): | |
| """Endpoint de santé global""" | |
| return { | |
| "status": "healthy", | |
| "service": "admission-api", | |
| "version": "1.0.0" | |
| } | |
| if __name__ == "__main__": | |
| import uvicorn | |
| uvicorn.run( | |
| "main:app", | |
| host=settings.host, | |
| port=settings.port, | |
| reload=settings.debug | |
| ) |