Spaces:
Sleeping
Sleeping
| # 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="20px", | |
| # ✨ REMOVED: The invalid 'layout_gap' argument | |
| ).set( | |
| # --- The .set() method is for colors and styles --- | |
| # Body/App Background | |
| body_background_fill="#f8f9fa", | |
| # Block/Card Styling | |
| block_background_fill="white", | |
| block_border_width="1px", | |
| block_border_color="#dee2e6", | |
| block_radius="16px", | |
| block_shadow="0 4px 6px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.05)", | |
| # Button Styling | |
| button_primary_background_fill="#005f73", | |
| button_primary_background_fill_hover="#0a9396", | |
| button_primary_text_color="white", | |
| # Input Textbox Styling | |
| input_background_fill="white", | |
| input_border_color="#dee2e6", | |
| input_shadow="*shadow_drop", | |
| input_border_width="1.5px", | |
| ) | |
| # --- 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() | |