#!/usr/bin/env python3
# Minimal static server for poc.html.
# Note: the iOS extraction path fires for any web-scheme URL
# (web::UrlHasWebScheme). For the IsEntitySelectionAllowedForURL
# allow-by-default gate in production Chrome iOS, serve over HTTPS
# from a non-IP hostname; for local testing http://localhost works
# to observe the unbounded WKScriptMessage being dispatched.
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):
        self.send_header('Cache-Control', 'no-store')
        super().end_headers()

with socketserver.TCPServer(('', PORT), H) as httpd:
    print(f'serving poc.html on http://localhost:{PORT}/poc.html')
    httpd.serve_forever()
