#!/usr/bin/env python3 """ Minimal dashboard to test callback structure """ import dash from dash import dcc, html, Input, Output import plotly.graph_objects as go from datetime import datetime import logging # Setup logging logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) # Create Dash app app = dash.Dash(__name__) # Simple layout app.layout = html.Div([ html.H1("Simple Test Dashboard"), html.Div(id="test-output"), dcc.Graph(id="test-chart"), dcc.Interval(id='test-interval', interval=2000, n_intervals=0) ]) # Simple callback @app.callback( Output('test-output', 'children'), Output('test-chart', 'figure'), Input('test-interval', 'n_intervals') ) def update_dashboard(n_intervals): """Simple callback to test basic functionality""" try: logger.info(f"Callback triggered: {n_intervals}") # Simple text output text_output = f"Update #{n_intervals} at {datetime.now().strftime('%H:%M:%S')}" # Simple chart fig = go.Figure() fig.add_trace(go.Scatter( x=[1, 2, 3, 4, 5], y=[n_intervals, n_intervals+1, n_intervals+2, n_intervals+1, n_intervals], mode='lines', name='Test Data' )) fig.update_layout( title=f"Test Chart - Update {n_intervals}", template="plotly_dark" ) logger.info(f"Returning: text='{text_output}', chart=
") return text_output, fig except Exception as e: logger.error(f"Error in callback: {e}") import traceback logger.error(f"Traceback: {traceback.format_exc()}") # Return safe fallback return f"Error: {str(e)}", go.Figure() if __name__ == "__main__": logger.info("Starting simple test dashboard on port 8052...") app.run(host='127.0.0.1', port=8052, debug=True)