MCPcopy Create free account
hub / github.com/TQZHR/grok2api / http_get

Function http_get

scripts/smoke_test.py:10–21  ·  view source on GitHub ↗
(url: str, *, headers: dict[str, str] | None = None, timeout: float = 5.0)

Source from the content-addressed store, hash-verified

8
9
10def http_get(url: str, *, headers: dict[str, str] | None = None, timeout: float = 5.0) -> tuple[int, bytes]:
11 req = Request(url, headers=headers or {}, method="GET")
12 try:
13 with urlopen(req, timeout=timeout) as resp:
14 return int(getattr(resp, "status", 200)), resp.read()
15 except HTTPError as e:
16 body = b""
17 try:
18 body = e.read()
19 except Exception:
20 pass
21 return int(getattr(e, "code", 0) or 0), body
22
23
24def http_post(

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected