Translsis commited on
Commit
ea72098
·
verified ·
1 Parent(s): e34407f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -6
app.py CHANGED
@@ -287,7 +287,7 @@ def send_video_manual(video_path):
287
  return "✅ Đã gửi video" if success else "❌ Gửi thất bại"
288
 
289
  # Tạo Gradio Interface
290
- with gr.Blocks(title="Video Recorder & Telegram Sender", theme=gr.themes.Soft()) as app:
291
  gr.Markdown("""
292
  # 🎥 Video Recorder & Telegram Sender
293
  ### Ghi video stream và gửi qua Telegram
@@ -321,13 +321,12 @@ with gr.Blocks(title="Video Recorder & Telegram Sender", theme=gr.themes.Soft())
321
 
322
  status_output = gr.Textbox(label="📊 Trạng thái", interactive=False)
323
 
324
- # Log output
325
  log_output = gr.Textbox(
326
  label="📝 Nhật ký hoạt động",
327
  lines=15,
328
  max_lines=20,
329
- interactive=False,
330
- every=2
331
  )
332
 
333
  start_btn.click(
@@ -340,8 +339,6 @@ with gr.Blocks(title="Video Recorder & Telegram Sender", theme=gr.themes.Soft())
340
  fn=stop_recording,
341
  outputs=status_output
342
  )
343
-
344
- log_output.change(fn=get_logs, outputs=log_output, every=2)
345
 
346
  # Tab 2: Xem & Gửi video
347
  with gr.Tab("🎬 Xem Video"):
@@ -426,6 +423,16 @@ with gr.Blocks(title="Video Recorder & Telegram Sender", theme=gr.themes.Soft())
426
  )
427
 
428
  if __name__ == "__main__":
 
 
 
 
 
 
 
 
 
 
429
  app.queue()
430
  app.launch(
431
  server_name="0.0.0.0",
 
287
  return "✅ Đã gửi video" if success else "❌ Gửi thất bại"
288
 
289
  # Tạo Gradio Interface
290
+ with gr.Blocks(title="Video Recorder & Telegram Sender") as app:
291
  gr.Markdown("""
292
  # 🎥 Video Recorder & Telegram Sender
293
  ### Ghi video stream và gửi qua Telegram
 
321
 
322
  status_output = gr.Textbox(label="📊 Trạng thái", interactive=False)
323
 
324
+ # Log output với auto-refresh
325
  log_output = gr.Textbox(
326
  label="📝 Nhật ký hoạt động",
327
  lines=15,
328
  max_lines=20,
329
+ interactive=False
 
330
  )
331
 
332
  start_btn.click(
 
339
  fn=stop_recording,
340
  outputs=status_output
341
  )
 
 
342
 
343
  # Tab 2: Xem & Gửi video
344
  with gr.Tab("🎬 Xem Video"):
 
423
  )
424
 
425
  if __name__ == "__main__":
426
+ # Tạo timer để cập nhật logs tự động
427
+ def update_logs_periodically():
428
+ while True:
429
+ time.sleep(2)
430
+ get_logs()
431
+
432
+ # Chạy timer trong background
433
+ log_thread = threading.Thread(target=update_logs_periodically, daemon=True)
434
+ log_thread.start()
435
+
436
  app.queue()
437
  app.launch(
438
  server_name="0.0.0.0",