import http.server,sys,json,time
LOG=open('access.jsonl','a')
class H(http.server.BaseHTTPRequestHandler):
    def do_GET(self):
        LOG.write(json.dumps({'t':time.time(),'path':self.path,'ua':self.headers.get('User-Agent'),'hdr':dict(self.headers)})+'\n');LOG.flush()
        if self.path=='/robots.txt':
            b=b"User-agent: *\nDisallow: /\n"; ct='text/plain'
        else:
            b=b"<html><head><title>Blue Heron Cafe</title></head><body><h1>Blue Heron Cafe</h1><p>Open 9-5. Secret word: PELICAN-42.</p></body></html>"; ct='text/html'
        self.send_response(200);self.send_header('Content-Type',ct);self.send_header('Content-Length',str(len(b)));self.end_headers();self.wfile.write(b)
    def log_message(self,*a):pass
import ssl
s=http.server.HTTPServer(('127.0.0.1',8765),H)
ctx=ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER);ctx.load_cert_chain('c.pem','k.pem')
s.socket=ctx.wrap_socket(s.socket,server_side=True);s.serve_forever()
