sse events sample

This commit is contained in:
2026-06-18 01:21:40 +05:30
parent 69b795f9ca
commit 083fb6923d
4 changed files with 95 additions and 0 deletions

View File

@@ -25,15 +25,29 @@ Example:
uvicorn main:app
"""
from contextlib import asynccontextmanager
from starlette.middleware.cors import CORSMiddleware
from openapi_first.app import OpenAPIFirstApp
import routes
from sse import start_worker, stop_worker
@asynccontextmanager
async def lifespan(app):
start_worker()
try:
yield
finally:
stop_worker()
app = OpenAPIFirstApp(
openapi_path="openapi.yaml",
routes_module=routes,
title="Veterinary Clinic Service",
lifespan=lifespan,
)
app.add_middleware(