Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,34 @@
|
|
1 |
-
# This is a simple Gradio app that translates Vietnamese to English using a pre-trained model.
|
2 |
import gradio as gr
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
#
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
)
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
|