24 lines
741 B
Python
24 lines
741 B
Python
import logging
|
|
|
|
import fastapi
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from pydantic import BaseModel
|
|
from fastapi import FastAPI,APIRouter
|
|
from db_setup import lifespan
|
|
from inbox.app import router as inbox_router
|
|
|
|
# Without this the db/migration logs have no handler and are swallowed under uvicorn.
|
|
logging.basicConfig(level=logging.INFO, format="%(levelname)-8s %(name)s: %(message)s")
|
|
|
|
# lifespan connects to Postgres and brings migrations up to head on startup,
|
|
# and disposes of the connection pool on shutdown.
|
|
app = FastAPI(lifespan=lifespan)
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
app.include_router(inbox_router) |