#!/usr/bin/env python3
"""Serve the dashboard locally on 127.0.0.1 using Python stdlib only."""
import http.server, socketserver, os
ROOT = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'dashboard')
os.chdir(ROOT)
PORT=8000
class _Handler(http.server.SimpleHTTPRequestHandler):
    def translate_path(self, path):
        # keep serving files from dashboard dir only
        return http.server.SimpleHTTPRequestHandler.translate_path(self, path)

def serve():
    with socketserver.TCPServer(('127.0.0.1', PORT), _Handler) as httpd:
        print(f"Serving dashboard at http://127.0.0.1:{PORT}/health_dashboard.html")
        try:
            httpd.serve_forever()
        except KeyboardInterrupt:
            httpd.shutdown()

if __name__=='__main__':
    serve()

