JSON-RPC: Клиентский запрос


--- client.py
  • client.py
#!/usr/bin/env python3

__author__ = 'RemiZOffAlex'
__email__ = 'remizoffalex@mail.ru'

import requests
import json


def main():
    url = "http://localhost:5000/jsonrpc"

    payload = {
        "method": "echo",
        "params": {
            "message": "Hello world!"
        },
        "jsonrpc": "2.0",
        "id": 0,
    }
    response = requests.post(url, json=payload).json()

    assert response["result"] == "Hello world!"
    assert response["jsonrpc"]
    assert response["id"] == 0

if __name__ == "__main__":
    main()

Ресурсы


GitLab
© RemiZOffAlex