I am tring to connect streamlit with socket-flast , so each change should be reflected on the ui, but I currently facing a promplem of Thread-23 (_handle_eio_message)': missing ScriptRunContext
. The data is printed in the console but shows error in streamlit app. this is my code demo.
import streamlit as st
import socketio
from threading import Lock
# Initialize session state
if 'sio' not in st.session_state:
st.session_state['sio'] = socketio.Client()
st.session_state['sio'].connect('http://localhost:5000')
if 'current_text' not in st.session_state:
st.session_state['current_text'] = ''
st.title('Real-time Text Viewer')
@st.session_state.sio.on('text_update')
def on_text_update(data):
print(data)
st.session_state['current_text'] = data['text']
# Display the current text
st.text(st.session_state['current_text'])
if st.button('Disconnect'):
st.session_state['sio'].disconnect()
st.write('Disconnected from server')