DeepLearning101 commited on
Commit
8354a5a
·
verified ·
1 Parent(s): 86289b0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -12,6 +12,10 @@ PUBLIC_SPACE_URL = "https://deeplearning101-ciecietaipei.hf.space"
12
 
13
  supabase: Client = create_client(SUPABASE_URL, SUPABASE_KEY)
14
 
 
 
 
 
15
  def get_bookings():
16
  response = supabase.table("bookings").select("*").order("created_at", desc=True).execute()
17
  if not response.data: return pd.DataFrame()
@@ -92,4 +96,9 @@ with gr.Blocks(title="Admin") as demo:
92
  action_btn.click(send_confirmation_email, inputs=id_input, outputs=log_output)
93
 
94
  if __name__ == "__main__":
95
- demo.launch()
 
 
 
 
 
 
12
 
13
  supabase: Client = create_client(SUPABASE_URL, SUPABASE_KEY)
14
 
15
+ # --- 讀取管理員帳號密碼 (從 Secrets 讀取更安全) ---
16
+ ADMIN_USER = os.getenv("ADMIN_USER")
17
+ ADMIN_PASSWORD = os.getenv("ADMIN_PASSWORD")
18
+
19
  def get_bookings():
20
  response = supabase.table("bookings").select("*").order("created_at", desc=True).execute()
21
  if not response.data: return pd.DataFrame()
 
96
  action_btn.click(send_confirmation_email, inputs=id_input, outputs=log_output)
97
 
98
  if __name__ == "__main__":
99
+ # 這裡做了修改:加入了 auth 參數
100
+ # 如果 Secrets 沒設定,預設帳密為 admin / 123456 (強烈建議去設定 Secrets!)
101
+ user = ADMIN_USER if ADMIN_USER else "admin"
102
+ pwd = ADMIN_PASSWORD if ADMIN_PASSWORD else "123456"
103
+
104
+ demo.launch(auth=(user, pwd))