Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
# ---
|
| 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
|
| 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 |
-
# ---
|
| 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 |
-
# ---
|
| 56 |
demo = create_ui(visit_count_html, theme=professional_theme)
|
| 57 |
|
| 58 |
-
# ---
|
| 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()
|