Spaces:
Sleeping
Sleeping
trying something else
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import streamlit as st
|
2 |
import uuid
|
|
|
3 |
|
4 |
def get_user_id():
|
5 |
if "user_id" not in st.session_state:
|
@@ -13,3 +14,32 @@ def get_user_id():
|
|
13 |
|
14 |
user_id = get_user_id()
|
15 |
st.write(f"Your unique ID is: {user_id}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
import uuid
|
3 |
+
import io, sys, time
|
4 |
|
5 |
def get_user_id():
|
6 |
if "user_id" not in st.session_state:
|
|
|
14 |
|
15 |
user_id = get_user_id()
|
16 |
st.write(f"Your unique ID is: {user_id}")
|
17 |
+
|
18 |
+
# Capture stdout
|
19 |
+
class StreamCapture(io.StringIO):
|
20 |
+
def __init__(self):
|
21 |
+
super().__init__()
|
22 |
+
self.output = []
|
23 |
+
|
24 |
+
def write(self, message):
|
25 |
+
self.output.append(message)
|
26 |
+
super().write(message)
|
27 |
+
|
28 |
+
def get_output(self):
|
29 |
+
return "".join(self.output)
|
30 |
+
|
31 |
+
# Redirect stdout to capture
|
32 |
+
capture = StreamCapture()
|
33 |
+
sys.stdout = capture
|
34 |
+
|
35 |
+
# Streamlit display section
|
36 |
+
st.title("Live Output Stream")
|
37 |
+
output_area = st.empty() # Placeholder for output display
|
38 |
+
|
39 |
+
# Infinite loop to print a number every 10 seconds
|
40 |
+
count = 1
|
41 |
+
while True:
|
42 |
+
print(f"Count: {count}")
|
43 |
+
output_area.text(capture.get_output()) # Update Streamlit with captured output
|
44 |
+
count += 1
|
45 |
+
time.sleep(10)
|