rapacious commited on
Commit
62124bc
·
verified ·
1 Parent(s): 73d0c15

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -10
app.py CHANGED
@@ -1,34 +1,33 @@
1
  import gradio as gr
2
  import os
3
- import time
4
  from datetime import datetime
5
 
6
- # Đọc firebase api key & url từ biến môi trường
7
  FIREBASE_API_KEY = os.getenv("FIREBASE_API_KEY", "Not Found")
8
  FIREBASE_URL = os.getenv("FIREBASE_URL", "Not Found")
9
 
10
- # Ghép lại thành dict dễ show
11
  firebase_info = {
12
  "FIREBASE_API_KEY": FIREBASE_API_KEY,
13
  "FIREBASE_URL": FIREBASE_URL
14
  }
15
 
16
- # Hàm cập nhật thời gian + show firebase info
17
  def display_info():
18
  current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
19
- content = f"### ⏰ Thời gian hiện tại:\n{current_time}\n\n"
20
- content += "### 🔐 Thông tin Firebase (từ Huggingface Secret):\n"
21
  for key, value in firebase_info.items():
22
  content += f"- **{key}**: {value}\n"
23
  return content
24
 
 
 
25
  with gr.Blocks() as demo:
26
- gr.Markdown("## Demo Thời gian & Firebase Variables từ Huggingface Secret")
27
 
28
  output = gr.Markdown(display_info)
29
 
30
- refresh_btn = gr.Button("🔄 Refresh")
31
-
32
- refresh_btn.click(fn=display_info, outputs=output)
33
 
34
  demo.launch()
 
1
  import gradio as gr
2
  import os
 
3
  from datetime import datetime
4
 
5
+ # Lấy biến môi trường (Firebase Secret)
6
  FIREBASE_API_KEY = os.getenv("FIREBASE_API_KEY", "Not Found")
7
  FIREBASE_URL = os.getenv("FIREBASE_URL", "Not Found")
8
 
 
9
  firebase_info = {
10
  "FIREBASE_API_KEY": FIREBASE_API_KEY,
11
  "FIREBASE_URL": FIREBASE_URL
12
  }
13
 
14
+ # Hàm tạo nội dung hiển thị
15
  def display_info():
16
  current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
17
+ content = f"## ⏰ Thời gian hiện tại:\n{current_time}\n\n"
18
+ content += "## 🔐 Thông tin Firebase (lấy từ Huggingface Secrets):\n"
19
  for key, value in firebase_info.items():
20
  content += f"- **{key}**: {value}\n"
21
  return content
22
 
23
+
24
+ # Giao diện Gradio
25
  with gr.Blocks() as demo:
26
+ gr.Markdown("## Demo Auto Update Thời gian & Firebase Variables")
27
 
28
  output = gr.Markdown(display_info)
29
 
30
+ # Timer auto update sau 1s
31
+ gr.Timer(display_info, every=1, outputs=output)
 
32
 
33
  demo.launch()