38 lines
990 B
Python
38 lines
990 B
Python
|
|
"""
|
||
|
|
Point d'entrée de l'application FastAPI.
|
||
|
|
|
||
|
|
Lancement en local : uvicorn app.main:app --reload
|
||
|
|
"""
|
||
|
|
|
||
|
|
from contextlib import asynccontextmanager
|
||
|
|
|
||
|
|
from fastapi import FastAPI
|
||
|
|
from fastapi.responses import RedirectResponse
|
||
|
|
from fastapi.staticfiles import StaticFiles
|
||
|
|
|
||
|
|
from app.database import init_db
|
||
|
|
from app.routers import categories, destinataires, materiels, scan
|
||
|
|
|
||
|
|
|
||
|
|
@asynccontextmanager
|
||
|
|
async def lifespan(app: FastAPI):
|
||
|
|
"""Crée les tables SQLite au démarrage si elles n'existent pas encore."""
|
||
|
|
init_db()
|
||
|
|
yield
|
||
|
|
|
||
|
|
|
||
|
|
app = FastAPI(title="Gestion de stock IT", lifespan=lifespan)
|
||
|
|
|
||
|
|
app.mount("/static", StaticFiles(directory="app/static"), name="static")
|
||
|
|
|
||
|
|
app.include_router(categories.router)
|
||
|
|
app.include_router(materiels.router)
|
||
|
|
app.include_router(scan.router)
|
||
|
|
app.include_router(destinataires.router)
|
||
|
|
|
||
|
|
|
||
|
|
@app.get("/")
|
||
|
|
def racine() -> RedirectResponse:
|
||
|
|
"""La page d'accueil redirige directement vers la liste des matériels."""
|
||
|
|
return RedirectResponse(url="/materiels")
|