@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")