#!/usr/bin/env python3 """ Simple HTTP server for Build Your Own X Explorer """ import http.server import socketserver import os PORT = 8000 class MyHTTPRequestHandler(http.server.SimpleHTTPRequestHandler): def end_headers(self): # Add CORS headers for local development self.send_header('Access-Control-Allow-Origin', '*') super().end_headers() def log_message(self, format, *args): # Custom logging print(f"[Server] {self.address_string()} - {format % args}") def run_server(): os.chdir('/workspace') with socketserver.TCPServer(("", PORT), MyHTTPRequestHandler) as httpd: print("=" * 60) print("šŸš€ Build Your Own X Explorer Server") print("=" * 60) print(f"šŸ“” Server running at: http://localhost:{PORT}") print(f"šŸ“‚ Serving files from: {os.getcwd()}") print("\nšŸŽÆ Open your browser and navigate to the URL above") print("\nāŒØļø Keyboard Shortcuts:") print(" • Ctrl+K - Focus search") print(" • Ctrl+R - Random tutorial (Surprise Me!)") print(" • Escape - Close modal") print("\nšŸ’” Press Ctrl+C to stop the server") print("=" * 60) print() try: httpd.serve_forever() except KeyboardInterrupt: print("\n\nšŸ‘‹ Server stopped. Goodbye!") httpd.shutdown() if __name__ == "__main__": run_server()