Skip to content

StreamingResponse class

Bases: EventSourceResponse

Response class for streaming server-sent events.

Follows the EventSource protocol

Constructor method.

Parameters:

Name Type Description Default
content Any

The content to stream.

iter(())

stream_response async

stream_response(send)

Streams data chunks to client by iterating over content.

If an exception occurs while iterating over content, an internal server error is sent to the client.

Parameters:

Name Type Description Default
send Send

The send function from the ASGI framework.

required