mailpilot / app /main.py
Yadav122's picture
push
cb2a233
raw
history blame
1.2 kB
"""Main FastAPI app instance declaration."""
import fastapi
from fastapi.middleware.cors import CORSMiddleware
import structlog
import uvicorn
from app.core.config import settings
from .core.middlewares import add_middlewares
from app.router import api_router
# Set up structlog for logging
logger = structlog.get_logger()
# Create FastAPI app with explicit paths
fastapi_app = fastapi.FastAPI(
title=settings.PROJECT_NAME,
version=settings.VERSION,
description=settings.DESCRIPTION,
openapi_url="/openapi.json", # Explicit path
docs_url="/docs", # Explicit path
redoc_url="/redoc", # Explicit path
)
# Add CORS middleware directly
fastapi_app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
fastapi_app.include_router(api_router)
add_middlewares(fastapi_app)
# Log the app startup
logger.info(
"Application started", project=settings.PROJECT_NAME, version=settings.VERSION
)
if __name__ == "__main__":
uvicorn.run(
"main:fastapi_app",
host=settings.UVICORN_HOST,
port=settings.UVICORN_PORT,
reload=True,
)