Skip to main content

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}

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.

Release history Release notifications | RSS feed

0.4.1

2 files

0.4

2 files

0.3.2

1 file

0.3.1

1 file

0.3

1 file

0.2.3

1 file

0.2.2

1 file

This release

0.2.1 This release

1 file

0.2

1 file

0.1

3 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page