def main(request, response): def fmt(x): return f'"{x.decode("utf-8")}"' if x is not None else "undefined" purpose = request.headers.get("Purpose", b"").decode("utf-8") sec_purpose = request.headers.get("Sec-Purpose", b"").decode("utf-8") headers = [(b"Content-Type", b"text/html"), (b'WWW-Authenticate', 'Basic')] status = 200 if request.auth.username is not None or sec_purpose.startswith( "prefetch") else 401 content = f''' ''' return status, headers, content