Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| """ | |
| Minimal working Gradio app to test deployment | |
| """ | |
| import gradio as gr | |
| import logging | |
| # Configure logging | |
| logging.basicConfig(level=logging.INFO) | |
| logger = logging.getLogger(__name__) | |
| def greet(name): | |
| """Simple greeting function""" | |
| logger.info(f"Greeting user: {name}") | |
| return f"Hello {name}! π Trading Dashboard works!" | |
| def refresh_data(): | |
| """Simple refresh function""" | |
| logger.info("Refreshing data...") | |
| return "Data refreshed! β " | |
| def create_minimal_dashboard(): | |
| """Create minimal dashboard to test Gradio""" | |
| logger.info("π Creating minimal dashboard...") | |
| with gr.Blocks(title="Test Dashboard") as demo: | |
| logger.info("π¨ Inside Blocks context...") | |
| gr.Markdown("# π§ͺ Test Trading Dashboard") | |
| with gr.Row(): | |
| name_input = gr.Textbox(label="Your Name", placeholder="Enter your name") | |
| greeting_output = gr.Textbox(label="Greeting", interactive=False) | |
| with gr.Row(): | |
| greet_btn = gr.Button("π Greet", variant="primary") | |
| refresh_btn = gr.Button("π Refresh", variant="secondary") | |
| status_output = gr.Textbox(label="Status", interactive=False) | |
| # Event handlers - INSIDE the Blocks context | |
| logger.info("π Setting up event handlers...") | |
| greet_btn.click( | |
| fn=greet, | |
| inputs=[name_input], | |
| outputs=[greeting_output] | |
| ) | |
| refresh_btn.click( | |
| fn=refresh_data, | |
| outputs=[status_output] | |
| ) | |
| # Initial load | |
| demo.load( | |
| fn=lambda: "Ready to test! π―", | |
| outputs=[status_output] | |
| ) | |
| demo.queue() | |
| logger.info("β Event handlers configured successfully") | |
| logger.info("β Dashboard created successfully") | |
| return demo | |
| if __name__ == "__main__": | |
| logger.info("π Starting minimal test dashboard...") | |
| try: | |
| demo = create_minimal_dashboard() | |
| logger.info("β Dashboard created successfully!") | |
| logger.info("π Launching dashboard server...") | |
| demo.launch() | |
| logger.info("β Dashboard launched successfully!") | |
| except Exception as e: | |
| logger.error(f"β Dashboard failed: {e}") | |
| raise |