#!/usr/bin/env python3
"""Serve the POC over HTTP.

Password generation requires the page to be served over HTTPS or from a
trustworthy origin. For local testing on Android, forward port 8443 with
adb reverse and use a self-signed certificate, or load via localhost which
Chrome treats as a secure context.
"""
import http.server
import socketserver
import sys

PORT = int(sys.argv[1]) if len(sys.argv) > 1 else 8080

class Handler(http.server.SimpleHTTPRequestHandler):
    def end_headers(self):
        self.send_header('Cache-Control', 'no-store')
        super().end_headers()

with socketserver.TCPServer(("0.0.0.0", PORT), Handler) as httpd:
    httpd.allow_reuse_address = True
    print(f"Serving on http://0.0.0.0:{PORT}", file=sys.stderr)
    httpd.serve_forever()
