Initial commit
This commit is contained in:
69
backend/main.py
Normal file
69
backend/main.py
Normal file
@@ -0,0 +1,69 @@
|
||||
"""
|
||||
InnotexBoard - Interface d'administration Debian
|
||||
Backend FastAPI
|
||||
"""
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.middleware.trustedhost import TrustedHostMiddleware
|
||||
import uvicorn
|
||||
from app.core.config import settings
|
||||
from app.api.routes import api_router
|
||||
from app.api.websocket import router as ws_router
|
||||
|
||||
# Initialiser l'application FastAPI
|
||||
app = FastAPI(
|
||||
title=settings.API_TITLE,
|
||||
description=settings.API_DESCRIPTION,
|
||||
version=settings.API_VERSION,
|
||||
)
|
||||
|
||||
# Middleware de sécurité CORS
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=settings.ALLOWED_ORIGINS,
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
# Middleware pour les hôtes de confiance
|
||||
app.add_middleware(
|
||||
TrustedHostMiddleware,
|
||||
allowed_hosts=["localhost", "127.0.0.1"],
|
||||
)
|
||||
|
||||
# Inclure les routes API
|
||||
app.include_router(api_router, prefix="/api/v1")
|
||||
app.include_router(ws_router, prefix="/api/v1")
|
||||
|
||||
|
||||
@app.get("/")
|
||||
async def root():
|
||||
"""Endpoint racine"""
|
||||
return {
|
||||
"message": "Bienvenue sur InnotexBoard",
|
||||
"version": settings.API_VERSION,
|
||||
"docs": "/docs",
|
||||
"openapi": "/openapi.json"
|
||||
}
|
||||
|
||||
|
||||
@app.get("/health")
|
||||
async def health_check():
|
||||
"""Vérification de la santé de l'application"""
|
||||
return {
|
||||
"status": "healthy",
|
||||
"service": "InnotexBoard API"
|
||||
}
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Configuration pour le développement
|
||||
uvicorn.run(
|
||||
"main:app",
|
||||
host="0.0.0.0",
|
||||
port=8000,
|
||||
reload=True,
|
||||
log_level="info",
|
||||
)
|
||||
Reference in New Issue
Block a user