-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdashboard_server.py
More file actions
40 lines (31 loc) · 1.22 KB
/
dashboard_server.py
File metadata and controls
40 lines (31 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import os
import sys
import webbrowser
import time
import pickle
from src.flw_summary_dashboard import create_flw_dashboard
def run_server(port=8080):
# Get the directory of the current script
script_dir = os.path.dirname(os.path.abspath(__file__))
# Load coverage data from pickle file
pickle_path = os.path.join(script_dir, 'coverage_data.pkl')
if not os.path.exists(pickle_path):
print("Error: coverage_data.pkl not found. Please run run_coverage.py first.")
return
try:
with open(pickle_path, 'rb') as f:
coverage_data_objects = pickle.load(f)
# Create the dashboard app
app = create_flw_dashboard(coverage_data_objects)
# Open the browser automatically
url = f'http://localhost:{port}'
print(f"Opening {url} in your browser...")
webbrowser.open(url)
# Give the browser a moment to open before starting the server
time.sleep(1)
print("Server is running. Press Ctrl+C to stop.")
app.run_server(debug=False, port=port)
except Exception as e:
print(f"Error loading dashboard: {str(e)}")
if __name__ == '__main__':
run_server()