tuhbooh commited on
Commit
544121d
·
verified ·
1 Parent(s): c6257c5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ import time # Import thêm thư viện thời gian
4
+
5
+ # Lấy các giá trị từ Secret của Hugging Face
6
+ SECRET_PASSWORD = os.environ.get("password")
7
+ SECRET_TEXT_A = os.environ.get("a")
8
+
9
+ def check_and_show(input_pw):
10
+ # Dừng hệ thống 1 giây để tránh brute force (tạo độ trễ phản hồi)
11
+ time.sleep(1)
12
+
13
+ if input_pw == SECRET_PASSWORD:
14
+ return f"✅ Password đúng! Nội dung bí mật là: {SECRET_TEXT_A}"
15
+ else:
16
+ return "❌ Sai password rồi!"
17
+
18
+ with gr.Blocks() as demo:
19
+ gr.Markdown("# 🛡️ Secure Space (Delay 1s)")
20
+
21
+ password_input = gr.Textbox(label="Nhập password", type="password")
22
+ submit_btn = gr.Button("Kiểm tra")
23
+ output_text = gr.Textbox(label="Kết quả")
24
+
25
+ submit_btn.click(fn=check_and_show, inputs=password_input, outputs=output_text)
26
+
27
+ if __name__ == "__main__":
28
+ # Max_threads giúp giới hạn số lượng request xử lý song song nếu cần
29
+ demo.launch()