Skip to content
Dashboard

FastAPI Lifespan Events are now supported on Vercel

from contextlib import asynccontextmanager
from fastapi import FastAPI
@asynccontextmanager
async def lifespan(app: FastAPI):
# Startup logic
print("Starting up...")
await startup_tasks()
yield
# Shutdown logic
await cleanup_tasks()
app = FastAPI(lifespan=lifespan)