This repository was archived by the owner on Dec 1, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,6 +17,14 @@ def list_dashboards():
1717 return [f .split ('.' )[0 ] for f in os .listdir (dashboards_dir ) if f .endswith ('.yml' )]
1818
1919
20+ def load_dashboard (dashboard_name ):
21+ dashboard_file = os .path .join ("dashboards" , f"{ dashboard_name } .yml" )
22+ if not os .path .exists (dashboard_file ):
23+ return None
24+ with open (dashboard_file , 'r' ) as f :
25+ return yaml .safe_load (f )
26+
27+
2028def load_dashboard (dashboard_name ):
2129 dashboard_file = os .path .join ("dashboards" , f"{ dashboard_name } .yml" )
2230 with open (dashboard_file , 'r' ) as f :
Original file line number Diff line number Diff line change 33from .context_init_cmd .main import init_context
44from .ask_cmd .main import query as ask_query
55from .chat_cmd .main import process_chat_message
6- from .report_cmd .main import generate_report_html
6+ from .report_cmd .main import generate_report_html , list_dashboards , load_dashboard
77import os
88
99app = Flask (__name__ )
@@ -52,6 +52,27 @@ def generate_report():
5252 return jsonify ({"error" : str (e )}), 500
5353
5454
55+ @app .route ('/dashboards' , methods = ['GET' ])
56+ def get_dashboards ():
57+ try :
58+ dashboards = list_dashboards ()
59+ return jsonify ({"dashboards" : dashboards })
60+ except Exception as e :
61+ return jsonify ({"error" : str (e )}), 500
62+
63+
64+ @app .route ('/dashboards/<dashboard_id>' , methods = ['GET' ])
65+ def get_dashboard (dashboard_id ):
66+ try :
67+ dashboard = load_dashboard (dashboard_id )
68+ if dashboard :
69+ return jsonify (dashboard )
70+ else :
71+ return jsonify ({"error" : "Dashboard not found" }), 404
72+ except Exception as e :
73+ return jsonify ({"error" : str (e )}), 500
74+
75+
5576def run_server (host = '0.0.0.0' , port = 8084 , debug = False ):
5677 app .run (host = host , port = port , debug = debug )
5778
You can’t perform that action at this time.
0 commit comments