Python Language Python Server Sent Events Flask SSE

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

@route("/stream")
def stream():
    def event_stream():
        while True:
            if message_to_send:
                yield "data: 
                    {}\n\n".format(message_to_send)"
    
    return Response(event_stream(), mimetype="text/event-stream")


Got any Python Language Question?