#!/usr/bin/env python3 """Local, illustrative audit fixture. Python standard library only; no Bing calls.""" import argparse from http.server import BaseHTTPRequestHandler, HTTPServer from urllib.parse import urlsplit PAGES = { "/product": ("Product fixture", "", [("X-Robots-Tag", "nocache")]), "/docs": ("Docs fixture", '', []), "/blog": ("Blog fixture", "", []), } class FixtureHandler(BaseHTTPRequestHandler): protocol_version = "HTTP/1.1" def do_GET(self): path = urlsplit(self.path).path if path == "/old-product": self.send_response(301) self.send_header("Location", "/product") self.send_header("X-Robots-Tag", "noarchive") self.send_header("Content-Length", "0") self.end_headers() return if path not in PAGES: self.send_error(404) return title, meta, headers = PAGES[path] body = (f'{title}' f'{meta}

{title}

' '

Illustrative local fixture, not a live client result.

').encode() self.send_response(200) self.send_header("Content-Type", "text/html; charset=utf-8") for name, value in headers: self.send_header(name, value) self.send_header("Content-Length", str(len(body))) self.end_headers() self.wfile.write(body) def log_message(self, *_args): pass if __name__ == "__main__": parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--port", type=int, default=8766) args = parser.parse_args() server = HTTPServer(("127.0.0.1", args.port), FixtureHandler) print(f"Fixture: http://127.0.0.1:{server.server_port}", flush=True) try: server.serve_forever() except KeyboardInterrupt: pass finally: server.server_close()