42 lines
1.0 KiB
Python
42 lines
1.0 KiB
Python
|
|
"""FastAPI application entry point."""
|
||
|
|
|
||
|
|
import logging
|
||
|
|
from contextlib import asynccontextmanager
|
||
|
|
|
||
|
|
from fastapi import FastAPI
|
||
|
|
from fastapi.middleware.cors import CORSMiddleware
|
||
|
|
|
||
|
|
from app.config import settings
|
||
|
|
from app.routers import contact, equipment, health
|
||
|
|
|
||
|
|
logging.basicConfig(level=logging.INFO)
|
||
|
|
logger = logging.getLogger(__name__)
|
||
|
|
|
||
|
|
|
||
|
|
@asynccontextmanager
|
||
|
|
async def lifespan(app: FastAPI):
|
||
|
|
"""Manage application startup and shutdown."""
|
||
|
|
logger.info("HMS Licht & Ton API starting up...")
|
||
|
|
yield
|
||
|
|
logger.info("HMS Licht & Ton API shutting down...")
|
||
|
|
|
||
|
|
|
||
|
|
app = FastAPI(
|
||
|
|
title="HMS Licht & Ton API",
|
||
|
|
description="Backend API for HMS Licht & Ton equipment rental platform.",
|
||
|
|
version="1.0.0",
|
||
|
|
lifespan=lifespan,
|
||
|
|
)
|
||
|
|
|
||
|
|
app.add_middleware(
|
||
|
|
CORSMiddleware,
|
||
|
|
allow_origins=settings.cors_origins_list,
|
||
|
|
allow_methods=["GET", "POST"],
|
||
|
|
allow_headers=["*"],
|
||
|
|
allow_credentials=True,
|
||
|
|
)
|
||
|
|
|
||
|
|
app.include_router(health.router, prefix="/api")
|
||
|
|
app.include_router(equipment.router, prefix="/api")
|
||
|
|
app.include_router(contact.router, prefix="/api")
|