Sync fastapi docs from 11614be9 on 2026-03-11
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
from collections.abc import AsyncIterable
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.sse import EventSourceResponse, ServerSentEvent
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
@app.get("/logs/stream", response_class=EventSourceResponse)
|
||||
async def stream_logs() -> AsyncIterable[ServerSentEvent]:
|
||||
logs = [
|
||||
"2025-01-01 INFO Application started",
|
||||
"2025-01-01 DEBUG Connected to database",
|
||||
"2025-01-01 WARN High memory usage detected",
|
||||
]
|
||||
for log_line in logs:
|
||||
yield ServerSentEvent(raw_data=log_line)
|
||||
Reference in New Issue
Block a user