cobot280pi / app.py
gursi26's picture
trying something else
fafda87
raw
history blame
1.17 kB
import streamlit as st
import uuid
import io, sys, time
def get_user_id():
if "user_id" not in st.session_state:
query_params = st.query_params
user_id = query_params.get("user_id", None)
if not user_id:
user_id = str(uuid.uuid4())
st.query_params["user_id"] = user_id
st.session_state.user_id = user_id
return st.session_state.user_id
user_id = get_user_id()
st.write(f"Your unique ID is: {user_id}")
# Capture stdout
class StreamCapture(io.StringIO):
def __init__(self):
super().__init__()
self.output = []
def write(self, message):
self.output.append(message)
super().write(message)
def get_output(self):
return "".join(self.output)
# Redirect stdout to capture
capture = StreamCapture()
sys.stdout = capture
# Streamlit display section
st.title("Live Output Stream")
output_area = st.empty() # Placeholder for output display
# Infinite loop to print a number every 10 seconds
count = 1
while True:
print(f"Count: {count}")
output_area.text(capture.get_output()) # Update Streamlit with captured output
count += 1
time.sleep(10)