Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/olemb/bottle_jsonrpc
A simple JSON-RPC implementation for Bottle
https://github.com/olemb/bottle_jsonrpc
Last synced: about 6 hours ago
JSON representation
A simple JSON-RPC implementation for Bottle
- Host: GitHub
- URL: https://github.com/olemb/bottle_jsonrpc
- Owner: olemb
- License: mit
- Created: 2012-07-16T08:44:34.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2017-01-26T15:11:39.000Z (almost 8 years ago)
- Last Synced: 2023-03-24T06:25:26.736Z (over 1 year ago)
- Language: Python
- Size: 14.6 KB
- Stars: 4
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.rst
- License: LICENSE
Awesome Lists containing this project
README
A simple JSON-RPC implementation for Bottle
===========================================``bottle_jsonrpc.py`` implements `JSON-RPC `_
for `Bottle `_ in a pretty straight forward way.Example
-------.. code-block:: python
import bottle_jsonrpc
jsonrpc = bottle_jsonrpc.register('/rpc')
@jsonrpc
def add(a, b):
return a + bAlternatively you can pass an object to ``register()``:
.. code-block:: python
class Methods(object):
def add(a, b):
return a + bbottle_jsonrpc.register('/rpc', Methods())
All public methods (callable attributes that don't start with ``_``)
will be exported as JSON-RPC methods.You can also manipulate the method dictionary directly:
.. code-block:: python
def add(a, b):
return a + bjsonrpc = bottle_jsonrpc.register('/rpc')
jsonrpc.methods['add'] = addArguments to register()
-----------------------Returns a ``NameSpace`` object that can also be used as a decorator.
path
Path that the client will send requests to. This will
be mounted in bottle with ``@post(path)``.obj=None
All public methods (callable attributes) of the object will
be exported as JSON-RPC methods.app=None
App to use. Defaults to ``bottle.default_app()``.NameSpace Attibutes
-------------------path, app
The values passed as arguments.methods
A dictionary of methods for lookup where name is the JSON-RPC methods name
and value is a callable object (typically a function or method).NameSpace Methods
-----------------add_object(obj)
Exports all public methods (callable attributes) of the object as JSON-RPC
methods.Status
------Should be considered experimental.
Error reporting (back to the JavaScript client) is not very good.
License
--------Released under the terms of the `MIT license
`_.Contact
--------Ole Martin Bjorndalen - [email protected]