Reoo88 commited on
Commit
032eee1
·
verified ·
1 Parent(s): e9bd29a

Update streamlit_app.py

Browse files
Files changed (1) hide show
  1. streamlit_app.py +11 -5
streamlit_app.py CHANGED
@@ -1,4 +1,4 @@
1
- import os, time, threading, urllib.request, subprocess
2
  import streamlit as st
3
 
4
  FONT_PATH = "/tmp/Palestine.ttf"
@@ -11,9 +11,15 @@ if not os.path.exists(FONT_PATH):
11
 
12
  def fetch_comments():
13
  try:
14
- urllib.request.urlretrieve(COMMENTS_URL, COMMENTS_FILE)
15
- except:
16
- pass
 
 
 
 
 
 
17
 
18
  def comments_updater():
19
  while True:
@@ -46,4 +52,4 @@ with st.form("f"):
46
  if st.form_submit_button("ابدأ"):
47
  if user and key:
48
  threading.Thread(target=start_stream, args=(key, user)).start()
49
- st.success("تم البث! التعليقات ستظهر من الخادم.")
 
1
+ import os, time, threading, subprocess, urllib.request, requests
2
  import streamlit as st
3
 
4
  FONT_PATH = "/tmp/Palestine.ttf"
 
11
 
12
  def fetch_comments():
13
  try:
14
+ r = requests.get(COMMENTS_URL, timeout=5)
15
+ if r.status_code == 200:
16
+ with open(COMMENTS_FILE, "w", encoding="utf-8") as f:
17
+ f.write(r.text)
18
+ print("✅ تم تحديث التعليقات")
19
+ else:
20
+ print(f"⚠️ فشل الجلب: {r.status_code}")
21
+ except Exception as e:
22
+ print(f"❌ خطأ في جلب التعليقات: {e}")
23
 
24
  def comments_updater():
25
  while True:
 
52
  if st.form_submit_button("ابدأ"):
53
  if user and key:
54
  threading.Thread(target=start_stream, args=(key, user)).start()
55
+ st.success("تم البث! التعليقات ستظهر باستمرار.")