cwadayi commited on
Commit
6f57c3d
·
verified ·
1 Parent(s): 921e711

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -13
app.py CHANGED
@@ -3,39 +3,39 @@ import gradio as gr
3
  from core.visits import get_and_update_visits
4
  from ui.layouts import create_ui
5
 
6
- # --- 1. 定義最終版的專業佈景主題 ---
7
  professional_theme = gr.themes.Soft(
8
- # 設定字體
9
  font=gr.themes.GoogleFont("Noto Sans TC"),
10
 
11
- # 設定色調
12
  primary_hue=gr.themes.colors.teal,
13
  secondary_hue=gr.themes.colors.cyan,
14
  neutral_hue="slate",
15
 
16
- # 設定元件圓角與間距
17
  radius_size=gr.themes.sizes.radius_md,
18
  spacing_size="20px",
19
- layout_gap="25px",
20
 
21
  ).set(
22
- # --- .set() 用於設定顏色與具體樣式 ---
23
- # 頁面背景
24
  body_background_fill="#f8f9fa",
25
 
26
- # 卡片/區塊樣式
27
  block_background_fill="white",
28
  block_border_width="1px",
29
  block_border_color="#dee2e6",
30
  block_radius="16px",
31
  block_shadow="0 4px 6px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.05)",
32
 
33
- # 按鈕樣式
34
  button_primary_background_fill="#005f73",
35
  button_primary_background_fill_hover="#0a9396",
36
  button_primary_text_color="white",
37
 
38
- # 輸入框樣式
39
  input_background_fill="white",
40
  input_border_color="#dee2e6",
41
  input_shadow="*shadow_drop",
@@ -43,7 +43,7 @@ professional_theme = gr.themes.Soft(
43
  )
44
 
45
 
46
- # --- 2. 應用程式啟動邏輯 ---
47
  try:
48
  count = get_and_update_visits()
49
  visit_count_html = f"🚀 **總載入次數:** {count}"
@@ -52,9 +52,9 @@ except Exception as e:
52
  visit_count_html = "🚀 **總載入次數:** N/A"
53
  print(f"Could not update visit count: {e}")
54
 
55
- # --- 3. 建立 UI 並傳入佈景主題 ---
56
  demo = create_ui(visit_count_html, theme=professional_theme)
57
 
58
- # --- 4. 啟動應用程式 ---
59
  if __name__ == "__main__":
60
  demo.launch()
 
3
  from core.visits import get_and_update_visits
4
  from ui.layouts import create_ui
5
 
6
+ # --- Corrected theme definition ---
7
  professional_theme = gr.themes.Soft(
8
+ # Set font
9
  font=gr.themes.GoogleFont("Noto Sans TC"),
10
 
11
+ # Set color hues
12
  primary_hue=gr.themes.colors.teal,
13
  secondary_hue=gr.themes.colors.cyan,
14
  neutral_hue="slate",
15
 
16
+ # Set component radius and spacing
17
  radius_size=gr.themes.sizes.radius_md,
18
  spacing_size="20px",
19
+ # ✨ REMOVED: The invalid 'layout_gap' argument
20
 
21
  ).set(
22
+ # --- The .set() method is for colors and styles ---
23
+ # Body/App Background
24
  body_background_fill="#f8f9fa",
25
 
26
+ # Block/Card Styling
27
  block_background_fill="white",
28
  block_border_width="1px",
29
  block_border_color="#dee2e6",
30
  block_radius="16px",
31
  block_shadow="0 4px 6px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.05)",
32
 
33
+ # Button Styling
34
  button_primary_background_fill="#005f73",
35
  button_primary_background_fill_hover="#0a9396",
36
  button_primary_text_color="white",
37
 
38
+ # Input Textbox Styling
39
  input_background_fill="white",
40
  input_border_color="#dee2e6",
41
  input_shadow="*shadow_drop",
 
43
  )
44
 
45
 
46
+ # --- Application startup logic (unchanged) ---
47
  try:
48
  count = get_and_update_visits()
49
  visit_count_html = f"🚀 **總載入次數:** {count}"
 
52
  visit_count_html = "🚀 **總載入次數:** N/A"
53
  print(f"Could not update visit count: {e}")
54
 
55
+ # --- Create UI with the corrected theme ---
56
  demo = create_ui(visit_count_html, theme=professional_theme)
57
 
58
+ # --- Launch the application ---
59
  if __name__ == "__main__":
60
  demo.launch()