diff --git a/examples/websocket-service/client.html b/examples/websocket-service/client.html index 5020678..8ba7fdb 100644 --- a/examples/websocket-service/client.html +++ b/examples/websocket-service/client.html @@ -1,103 +1,491 @@ - + - Wyoming Satellite WebSocket + Wyoming Satellite Control -
-
-

šŸ›°ļø Wyoming Satellite WebSocket

-
Connecting...
+
+ +
+
+

šŸ›°ļø Wyoming Satellite Control

+
WebSocket Client & Audio Level Monitor
+
+
+ Connecting... +
-
- - + + +
+ + +
+ + +
+
+ + +
+ +
+

šŸ”Š Volume Control

+ +
+ + +
100%
+
+ +
+ + +
+
+ + +
+

šŸ“Š RMS Audio Level

+ +
+
+
+
+
0.00
+
Real-time microphone level
+
+ +
+ +
+
+ + +
+

šŸ’” LED Control

+ +
+ + +
128
+
+ +
+ + + +
+
+
+ + +
+

šŸ“‹ Event Log

+
+ + + +
+
- - - -
diff --git a/examples/websocket-service/start_web_server.py b/examples/websocket-service/start_web_server.py new file mode 100755 index 0000000..9c0b93a --- /dev/null +++ b/examples/websocket-service/start_web_server.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python3 +""" +Simple HTTP server for WebSocket client testing. + +Usage: + python3 start_web_server.py [--port PORT] + +Open in browser: + http://localhost:PORT/client.html +""" + +import argparse +import http.server +import socketserver +import os +from pathlib import Path + +PORT = 8080 +SCRIPT_DIR = Path(__file__).parent.resolve() + + +class CustomHandler(http.server.SimpleHTTPRequestHandler): + """Custom handler with better logging.""" + + def do_GET(self): + super().do_GET() + self.log_message(f"āœ… Served: {self.path}") + + def log_message(self, format, *args): + print(f"[WebServer] {args[0]}") + + +def main(): + parser = argparse.ArgumentParser(description='WebSocket Client Web Server') + parser.add_argument('--port', type=int, default=PORT, help=f'Port (default: {PORT})') + parser.add_argument('--host', default='0.0.0.0', help='Host (default: 0.0.0.0)') + args = parser.parse_args() + + # Change to websocket-service directory + os.chdir(SCRIPT_DIR) + + print(f""" +╔══════════════════════════════════════════════════════════╗ +ā•‘ šŸ›°ļø Wyoming Satellite WebSocket Client Server ā•‘ +╠══════════════════════════════════════════════════════════╣ +ā•‘ Serving: {str(SCRIPT_DIR):<45} ā•‘ +ā•‘ URL: http://localhost:{args.port:<36} ā•‘ +ā•‘ ā•‘ +ā•‘ Press Ctrl+C to stop ā•‘ +ā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā• + """) + + with socketserver.TCPServer((args.host, args.port), CustomHandler) as httpd: + try: + print(f"šŸš€ Server started on http://{args.host}:{args.port}") + httpd.serve_forever() + except KeyboardInterrupt: + print("\nšŸ‘‹ Shutting down...") + httpd.shutdown() + + +if __name__ == "__main__": + main()