26 lines · python
1import http.server2import os3import subprocess4import sys5import threading6 7 8class TrivialHandler(http.server.BaseHTTPRequestHandler):9 def do_GET(self):10 self.send_response(501)11 12 def log_request(self, *args, **kwargs):13 print(self.requestline)14 print(self.headers)15 16 17httpd = http.server.HTTPServer(("", 0), TrivialHandler)18port = httpd.socket.getsockname()[1]19 20try:21 t = threading.Thread(target=httpd.serve_forever).start()22 os.environ["DEBUGINFOD_URLS"] = f"http://localhost:{port}"23 subprocess.run(sys.argv[1:], capture_output=True)24finally:25 httpd.shutdown()26