cenobites / flask-jsonrpc

Basic JSON-RPC implementation for your Flask-powered sites

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Minimum Python Client Example

sistemicorp opened this issue · comments

Prior to version 1.0, for a python flask client, I was using,

from flask_jsonrpc.proxy import ServiceProxy

based on the example here and here

but ServiceProxy no longer imports, and I can't find any documentation on how to jsonrpc from python.

Hi,

The ServiceProxy was removed from the code base, you can copy from here and use it.

Or, you can use the requests for this. Follow the example with consume the method App.index from this:

$ python
>>> import requests 
>>> r = requests.post('http://localhost:5000/api', json={'id': '1', 'jsonrpc': '2.0', 'method': 'App.index'})
>>> r.json()
{'id': '1', 'jsonrpc': '2.0', 'result': 'Welcome to Flask JSON-RPC'}

Thank you.