Open raw ↗"""
HAD Digital - Improved MVP Launcher
Serves the improved HTML interface
"""
import http.server
import socketserver
import json
import os
import sys
import webbrowser
import threading
from pathlib import Path
PORT = 8080
HOST = "127.0.0.1"
def get_base_dir():
"""Get the base directory for resources"""
if getattr(sys, 'frozen', False):
# When frozen, look in _internal folder
return Path(sys.executable).parent / "_internal"
return Path(__file__).parent
BASE_DIR = get_base_dir()
STATIC_DIR = BASE_DIR / "static"
class HADHandler(http.server.SimpleHTTPRequestHandler):
def __init__(self, *args, **kwargs):
super().__init__(*args, directory=str(STATIC_DIR), **kwargs)
def do_GET(self):
if self.path == '/' or self.path == '/index.html':
self.path = '/HAD_Digital_Improved.html'
return super().do_GET()
def end_headers(self):
self.send_header('Access-Control-Allow-Origin', '*')
self.send_header('Cache-Control', 'no-cache')
super().end_headers()
def log_message(self, format, *args):
pass
def main():
# Ensure static directory exists
STATIC_DIR.mkdir(exist_ok=True)
# Check if HTML file exists
html_file = STATIC_DIR / "HAD_Digital_Improved.html"
if not html_file.exists():
print(f"ERROR: {html_file} not found!")
print(f"Static directory: {STATIC_DIR}")
print(f"Contents: {list(STATIC_DIR.glob('*'))}")
input("Press Enter to exit...")
return
print(f"""
============================================
HAD Digital - Improved MVP
Home Hospitalization Platform v2.0
============================================
Server: http://{HOST}:{PORT}
Demo Accounts:
- Patient: patient.durand / demo123
- Nurse: inf.moret / demo123
- Doctor: dr.martin / demo123
- Admin: admin / admin123
Features:
- Role-based interfaces (Patient/Nurse/Doctor)
- Medication tracking
- Symptom reporting (CTCAE-based)
- Daily vital signs
- Alert management
- Care team messaging
Press Ctrl+C to stop
============================================
""")
# Open browser after short delay
def open_browser():
import time
time.sleep(1.5)
webbrowser.open(f"http://{HOST}:{PORT}")
threading.Thread(target=open_browser, daemon=True).start()
# Start server
with socketserver.TCPServer((HOST, PORT), HADHandler) as httpd:
try:
httpd.serve_forever()
except KeyboardInterrupt:
print("\nShutting down...")
httpd.shutdown()
if __name__ == '__main__':
main()