Skip to main content

jsonrpc implementation for tornado

Project description

JSON RPC implementation for tornado
===================================

This implementation follow JSONRPC 2.0 specification.

REQUIREMENTS
------------

python >= 3.5 (I use async/await in the package)

INSTALLATION
------------

pip install tornado_jsonrpc

USAGE
-----

It is so simple:

1. Just create `views.py`

def some_view(request: RequestHandler, *args, **kwargs): #
"""
args: positional params, which You pass when call jsonrpc method
kwargs: named params, which You pass when call jsonrpc method
"""

return {'foo': 'bar'} # any JSON serializable object (dict or list for example)

2. And then create `tornado_app.py`, where You define tornado Application:

from tornado_jsonrpc import JSONRPCHandler
from tornado.ioloop import IOLoop
from tornado.web import Application

from your_package import views

Application(
[
('/api', views.JSONRPCHandler, dict(views=views)),
],
).listen(8888)

IOLoop.current().start()

3. You can also use CORSIgnoreJSONRPCHandler to receive requests from all sources
or WithCredentialsJSONRPCHandler to also receive cookies with request.

CONTRIBUTE
----------

If You have found an error or want to offer changes - create a pull request and I will review it as soon as possible!


Project details


Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
tornado_jsonrpc-1.0.4-py2.py3-none-any.whl (9.2 kB) Copy SHA256 hash SHA256 Wheel py2.py3
tornado_jsonrpc-1.0.4.tar.gz (3.1 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page