Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
# This file: # http://anggtwu.net/JSONRPC/quickstart-client.py.html # http://anggtwu.net/JSONRPC/quickstart-client.py # (find-angg "JSONRPC/quickstart-client.py") # See: (find-angg "JSONRPC/quickstart-server.py") # Code from: https://json-rpc.readthedocs.io/en/latest/quickstart.html # Adapted by: Eduardo Ochs <eduardoochs@gmail.com> import requests import json def main(): url = "http://localhost:4000/jsonrpc" headers = {'content-type': 'application/json'} # Example echo method payload = { "jsonrpc":"2.0", "id":0, "method":"echo", "params":["echome!"], } response = requests.post( url, data=json.dumps(payload), headers=headers).json() assert response["result"] == "echome!" assert response["jsonrpc"] assert response["id"] == 0 if __name__ == "__main__": main() """ * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) python3 jsonrpc-client.py * (eepitch-python) * (eepitch-kill) * (eepitch-python) import requests import json url = "http://localhost:4000/jsonrpc" headers = {'content-type': 'application/json'} payload1 = {"jsonrpc":"2.0", "id":0, "method":"echo", "params":["echome!"]} response = requests.post(url, data=json.dumps(payload1), headers=headers).json() response """