18 lines
441 B
Python
18 lines
441 B
Python
"""Tiny client for the Buryans Tool Gateway."""
|
|
import json
|
|
import urllib.request
|
|
|
|
BASE = "http://127.0.0.1:9137"
|
|
|
|
|
|
def call(tool):
|
|
with urllib.request.urlopen(BASE + "/v1/call?tool=" + tool, timeout=25) as r:
|
|
d = json.loads(r.read().decode())
|
|
body = d.get("body")
|
|
if isinstance(body, str):
|
|
try:
|
|
return json.loads(body)
|
|
except Exception:
|
|
return {"raw": body}
|
|
return body or {}
|