Skip to main content

WSGI Framework for JSON RPC 2.0

Project description

jsonrpc2 is WSGI Framework for JSON RPC 2.0. JSON RPC 2.0 Spec can be seen on http://groups.google.com/group/json-rpc/web/json-rpc-2-0

>>> import simplejson as json
>>> from jsonrpc2 import JsonRpcApplication

sample procedure:

>>> def greeting(name="world"):
...     return "Hello, %s!" % name

create rpc application:

>>> app = JsonRpcApplication(rpcs=dict(greeting=greeting))

set up for test:

>>> from webtest import TestApp
>>> testapp = TestApp(app)

call procedure:

>>> call_values = {'jsonrpc':'2.0', 'method':'greeting', 'id':'greeting'}
>>> res = testapp.post('/', params=json.dumps(call_values), content_type="application/json")

got results:

>>> res.json
{'jsonrpc': '2.0', 'id': 'greeting', 'result': 'Hello, world!'}

lazy loading:

>>> app.rpc.methods['sample.add'] = 'tests.sample:add'
>>> call_values = {'jsonrpc':'2.0', 'method':'sample.add', 'id':'sample.add', 'params':[1, 2]}
>>> res = testapp.post('/', params=json.dumps(call_values), content_type="application/json")
>>> res.json
{'jsonrpc': '2.0', 'id': 'sample.add', 'result': 3}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jsonrpc2-0.2.1.tar.gz (4.7 kB view details)

Uploaded Source

File details

Details for the file jsonrpc2-0.2.1.tar.gz.

File metadata

  • Download URL: jsonrpc2-0.2.1.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for jsonrpc2-0.2.1.tar.gz
Algorithm Hash digest
SHA256 399802086ecc0e9cfdd1906f73b8d42b2dabf5c7dcef99f54ed3800e89f15e23
MD5 1659a5905c294f382939fcceb61c4b08
BLAKE2b-256 ef394197487f91e4fd6ff34f5d371da9f2c3d9f537398328322a0197a1a3c205

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page