INNER CODE UNIT · Python
_html
shuvonsec/claude-bug-bounty · demo/app.py:118
def _html(body: str, status: int = 200) -> tuple[int, bytes, dict]:
return status, body.encode("utf-8"), {"Content-Type": "text/html; charset=utf-8"}
def _text(body: str, status: int = 200) -> tuple[int, bytes, dict]:
return status, body.encode("utf-8"), {"Content-Type": "text/plain; charset=utf-8"}
def _json(obj, status: int = 200) -> tuple[int, bytes, dict]:
return status, json.dumps(obj, indent=2).encode("utf-8"), {"Content-Type": "application/json"}
class DemoHandler(BaseHTTPRequestHandler):
server_version = "shuvonsec/1.0"
# Quiet the default per-request access log so the recording stays clean.
def log_message(self, fmt, *args): # noqa: A003
sys.stderr.write("%s - %s\n" % (self.address_string(), fmt % args))