INNER CODE UNIT · Python
_json
shuvonsec/claude-bug-bounty · demo/app.py:126
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))
def _send(self, status: int, body: bytes, headers: dict) -> None:
self.send_response(status)
for k, v in headers.items():
self.send_header(k, v)
self.send_header("Content-Length", str(len(body)))
self.send_header("X-Powered-By", "shuvonsec/1.0")
self.end_headers()