cwadayi's picture
Update app.py
1dffa77 verified
raw
history blame
2.26 kB
# app.py
import gradio as gr
from core.visits import get_and_update_visits
from ui.layouts import create_ui
# --- Corrected theme definition ---
professional_theme = gr.themes.Soft(
# Set font
font=gr.themes.GoogleFont("Noto Sans TC"),
# Set color hues
primary_hue=gr.themes.colors.teal,
secondary_hue=gr.themes.colors.cyan,
neutral_hue="slate",
# Set component radius and spacing
radius_size=gr.themes.sizes.radius_md,
spacing_size=gr.themes.sizes.spacing_md,
).set(
# === Global Layout ===
body_background_fill="#f8f9fa",
panel_background_fill="#f8f9fa",
# === Block/Card Styling ===
block_background_fill="white",
block_border_width="0px",
block_border_color="transparent",
block_radius="16px",
block_shadow="0 4px 10px rgba(0, 0, 0, 0.08)",
# === Unselected Tabs (Secondary Button) Styling ===
button_secondary_background_fill="transparent",
button_secondary_background_fill_hover="rgba(0, 0, 0, 0.05)",
button_secondary_text_color="#6c757d",
button_secondary_text_color_hover="#005f73",
# ✨ CORRECTED: Removed invalid 'button_secondary_radius' argument
# === Primary Button Styling (also applies to selected tabs) ===
button_primary_background_fill="#005f73",
button_primary_background_fill_hover="#0a9396",
button_primary_text_color="white",
button_primary_radius="8px",
# === Input Textbox Styling ===
input_background_fill="white",
input_border_color="#dee2e6",
input_shadow="0 1px 3px rgba(0, 0, 0, 0.08)",
input_border_width="1.5px",
input_radius="8px",
# --- Other details ---
link_text_color="#0a9396",
link_text_color_hover="#005f73",
)
# --- Application startup logic (unchanged) ---
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}")
# --- Create UI with the corrected theme ---
demo = create_ui(visit_count_html, theme=professional_theme)
# --- Launch the application ---
if __name__ == "__main__":
demo.launch()