#!/usr/bin/env python3
"""Serves the POC files on http://localhost:8080/."""
import http.server, socketserver, os, sys

PORT = int(sys.argv[1]) if len(sys.argv) > 1 else 8080
os.chdir(os.path.dirname(os.path.abspath(__file__)))

class H(http.server.SimpleHTTPRequestHandler):
    def end_headers(self):
        # localhost is already a secure context; no extra headers needed.
        super().end_headers()
    def log_message(self, fmt, *args):
        sys.stderr.write("[server] %s\n" % (fmt % args))

socketserver.TCPServer.allow_reuse_address = True
with socketserver.TCPServer(("", PORT), H) as httpd:
    print(f"[server] http://localhost:{PORT}/opener.html", flush=True)
    httpd.serve_forever()
