MCPcopy Create free account
hub / github.com/CodeClash-ai/CodeClash / do_GET

Method do_GET

codeclash/replay/serve.py:56–75  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

54
55 class Handler(BaseHTTPRequestHandler):
56 def do_GET(self):
57 parsed = urllib.parse.urlparse(self.path)
58 if parsed.path in ("/", "/index.html"):
59 self._html(base.build_index(tour))
60 return
61 if parsed.path == "/game":
62 q = urllib.parse.parse_qs(parsed.query)
63 try:
64 idx = int(q["g"][0])
65 game = tour.games[idx]
66 except (KeyError, ValueError, IndexError):
67 self.send_error(404, "no such game")
68 return
69 try:
70 self._html(render_game(game))
71 except Exception as exc: # one bad game shouldn't take down the server
72 print(f"[replay] failed to render game {idx}: {type(exc).__name__}: {exc}")
73 self._html(error_page(game, exc), status=500)
74 return
75 self.send_error(404)
76
77 def _html(self, page: str, status: int = 200):
78 body = page.encode()

Callers

nothing calls this directly

Calls 3

_htmlMethod · 0.95
render_gameFunction · 0.85
error_pageFunction · 0.85

Tested by

no test coverage detected