File size: 1,486 Bytes
57b8366
8eb449d
57b8366
 
 
8eb449d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57b8366
 
 
 
 
 
 
 
8eb449d
 
57b8366
8eb449d
57b8366
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# app.py
import gradio as gr
from core.visits import get_and_update_visits
from ui.layouts import create_ui

# --- ✨ 1. Define a new custom theme for better aesthetics ---
custom_theme = gr.themes.Soft(
    primary_hue="blue",
    secondary_hue="cyan",
    neutral_hue="slate",
    spacing_size=gr.themes.sizes.spacing_md,
    radius_size=gr.themes.sizes.radius_md,
).set(
    # Custom colors
    body_background_fill="#F0F4F8",          # A light blue-gray for the main background
    block_background_fill="white",           # White background for components
    block_border_width="1px",                # Thin border for components
    block_shadow="*shadow_drop_lg",          # Soft shadow for a floating effect
    
    # Custom button style
    button_primary_background_fill="*primary_500",
    button_primary_background_fill_hover="*primary_400",
    button_primary_text_color="white",
)

# --- 2. Update site visit count on startup ---
try:
    count = get_and_update_visits()
    visit_count_html = f"🚀 **總載入次數:** {count}"
    print(f"Application loaded. Total visits: {count}")
except Exception as e:
    visit_count_html = "🚀 **總載入次數:** N/A"
    print(f"Could not update visit count: {e}")

# --- 3. Create the main UI, passing both dynamic content and the new theme ---
demo = create_ui(visit_count_html, theme=custom_theme)

# --- 4. Launch the application ---
if __name__ == "__main__":
    demo.launch()