2025-02-19 16:59:34 +01:00

36 lines
946 B
Python

from contextlib import asynccontextmanager
from fastapi import Depends, FastAPI
from fastapi.middleware.cors import CORSMiddleware
from .middleware.authenticate import authenticate
from .providers.db_provider import create_db_and_tables
from .routers.houses import router as houses_router
from .routers.owners import router as owners_router
@asynccontextmanager
async def lifespan(_app: FastAPI):
create_db_and_tables()
yield
app = FastAPI(
title="Fair Housing API",
description="Provides access to core functionality for the fair housing platform.",
version="1.0.0",
lifespan=lifespan,
dependencies=[Depends(authenticate)],
)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(houses_router, prefix="/houses", tags=["houses"])
app.include_router(owners_router, prefix="/owners", tags=["owners"])