48 lines
967 B
Python
48 lines
967 B
Python
"""
|
|
Application FastAPI principale.
|
|
"""
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from .config import settings
|
|
from .database import init_db
|
|
from .routes import router
|
|
|
|
# Initialiser la base de données
|
|
init_db()
|
|
|
|
# Créer l'application FastAPI
|
|
app = FastAPI(
|
|
title=settings.app_name,
|
|
version=settings.app_version,
|
|
debug=settings.debug
|
|
)
|
|
|
|
# Configuration CORS
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"], # À restreindre en production
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Inclure les routes
|
|
app.include_router(router)
|
|
|
|
|
|
@app.get("/health")
|
|
async def health_check():
|
|
"""Vérifier l'état de l'application"""
|
|
return {"status": "ok", "version": settings.app_version}
|
|
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
"""Endpoint root"""
|
|
return {
|
|
"name": settings.app_name,
|
|
"version": settings.app_version,
|
|
"docs": "/docs"
|
|
}
|