Skip to content

Instantly share code, notes, and snippets.

@mneedham
Created April 23, 2024 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mneedham/9ec7be66021e5f18a618524ec0077990 to your computer and use it in GitHub Desktop.
Save mneedham/9ec7be66021e5f18a618524ec0077990 to your computer and use it in GitHub Desktop.
import streamlit as st
import json
from sseclient import SSEClient
print("Listening for updates...")
if "messages" in st.session_state:
print("Closing old connection")
st.session_state["messages"].resp.close()
url = "http://127.0.0.1:8000/livetext"
st.session_state["messages"] = SSEClient(url)
placeholder = st.empty()
with placeholder.container():
for msg in st.session_state["messages"]:
if msg.data:
st.write(json.loads(msg.data))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment