#!/usr/bin/env python3
"""Tiny localhost HTTP server for the CH-020 PoC.

Serves poc.html from the current directory on http://127.0.0.1:8765/.
Localhost HTTP is a Secure Context in Chrome, so OPFS and
FileSystemObserver are exposed without needing HTTPS certs.
"""
from http.server import HTTPServer, SimpleHTTPRequestHandler
import sys

PORT = 8765


class H(SimpleHTTPRequestHandler):
    def log_message(self, fmt, *args):
        sys.stderr.write("[server] " + (fmt % args) + "\n")


if __name__ == "__main__":
    httpd = HTTPServer(("127.0.0.1", PORT), H)
    print(f"[server] serving ./ on http://127.0.0.1:{PORT}/")
    httpd.serve_forever()
