34 lines
832 B
Python
34 lines
832 B
Python
from typing import Awaitable, Callable
|
|
|
|
from fastapi import FastAPI, Request, Response
|
|
from fastapi.staticfiles import StaticFiles
|
|
from middleware.validation import validate_json
|
|
from config.database import Base, engine
|
|
from models import (
|
|
FinancialInput,
|
|
Project,
|
|
Scenario,
|
|
SimulationParameter,
|
|
)
|
|
|
|
# Initialize database schema (imports above ensure models are registered)
|
|
Base.metadata.create_all(bind=engine)
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
@app.middleware("http")
|
|
async def json_validation(
|
|
request: Request, call_next: Callable[[Request], Awaitable[Response]]
|
|
) -> Response:
|
|
return await validate_json(request, call_next)
|
|
|
|
|
|
@app.get("/health", summary="Container health probe")
|
|
async def health() -> dict[str, str]:
|
|
return {"status": "ok"}
|
|
|
|
|
|
app.mount("/static", StaticFiles(directory="static"), name="static")
|
|
|