When developing a Server-Sent Events (SSE) service based on the built-in Flask in a Dash application, running it locally allows normal access to the corresponding SSE interface for streaming data return:

However, after the same application is published to Plotly Cloud, the corresponding application and interface access encounter abnormalities:
- Example application: https://2c55246f-8a50-49b8-87d3-048924564831.plotly.app
- Corresponding SSE interface: Waking up the app...
Due to issues in this regard, it is impossible to deploy LLM applications that rely on streaming responses.
Example application code:
import time
import json
import dash
from dash import html
from flask import Response
app = dash.Dash(__name__)
@app.server.route("/stream")
def stream():
def _stream():
for i in range(999):
time.sleep(1)
yield "data: {}\n\n".format(json.dumps({"timestamp": time.time()}))
return Response(_stream(), mimetype="text/event-stream")
app.layout = html.Div(
["SSE Example: ", html.A("/stream", href="/stream")], style={"padding": 50}
)
if __name__ == "__main__":
app.run(debug=True)