You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
FreeDMR/api_client.py

27 lines
695 B

import json
import sys
from urllib import request
def post(path, payload):
body = json.dumps(payload).encode("utf-8")
req = request.Request(
"http://127.0.0.1:8000" + path,
data=body,
headers={"content-type": "application/json"},
method="POST",
)
with request.urlopen(req, timeout=3) as response:
return json.loads(response.read().decode("utf-8"))
if __name__ == "__main__":
if len(sys.argv) != 4:
print("usage: api_client.py <dmrid> <key> <options>")
raise SystemExit(2)
print(post("/api/v1/options/set", {
"dmrid": int(sys.argv[1]),
"key": sys.argv[2],
"options": sys.argv[3],
}))

Powered by TurnKey Linux.