πŸ’­ sysid/sse-starlette ━━━━━━━━━━━━━━━━━━━━━ !https://github.com/sysid/sse-starlette Date: October 12, 2023 Image: GitHub - sysid/sse-starlette β€” Contribute to sysid/sse-starlette development by creating an account on GitHub. GitHub - sysid/sse-starlette Contribute to sysid/sse-starlette development by creating an account on GitHub. GitHub Β· github.com sse-FastAPI </starlette/>.">starlette provides server sent events for startlette and FastApi. I’m evaluating for use with htmx </htmx/>. Installation: ───────────── [code] pip install sse-starlette Usage: ────── [code] import asyncio import uvicorn from starlette.applications import Starlette from starlette.routing import Route from sse_starlette.sse import EventSourceResponse async def numbers(minimum, maximum): for i in range(minimum, maximum + 1): await asyncio.sleep(0.9) yield dict(data=i) async def sse(request): generator = numbers(1, 5) return EventSourceResponse(generator) routes = [ Route("/", endpoint=sse) ] app = Starlette(debug=True, routes=routes) if __name__ == "__main__": uvicorn.run(app, host="0.0.0.0", port=8000, log_level='info') NOTE β”‚ This post is a thought </thoughts/>. It’s a short note that I make about someone else’s content online #thoughts </tags/thoughts/>