Skip to main content

EventSourceResponse

Streaming response with text/event-stream media type.

Attributes

AttributeTypeDescription
media_typestring = text/event-streamThe HTTP Content-Type header value used to identify the response as a Server-Sent Events stream.

Constructor

Signature

def EventSourceResponse() - > null

Signature

def EventSourceResponse(
content: Any,
status_code: int = 200,
headers: dict = null,
media_type: str = text/event-stream,
background: BackgroundTask = null
) - > null

Parameters

NameTypeDescription
contentAnyThe iterable or generator yielding the event stream data
status_codeint = 200The HTTP status code for the response
headersdict = nullA dictionary of HTTP headers to include in the response
media_typestr = text/event-streamThe mime type for the response, defaulting to the SSE standard
backgroundBackgroundTask = nullA background task to run after the response has been sent