Skip to main content

Simple and modern JSON-RPC and XML-RPC server implementation for Django

Project description

https://travis-ci.org/alorence/django-modern-rpc.svg?branch=master https://coveralls.io/repos/github/alorence/django-modern-rpc/badge.svg?branch=master https://readthedocs.org/projects/django-modern-rpc/badge/?version=latest https://badge.fury.io/py/django-modern-rpc.svg https://img.shields.io/badge/demo-online-green.svg

Description

django-modern-rpc is a free, lightweight RPC server for Django projects. The library is available on PyPi.

  • XML-RPC and JSON-RPC 2.0 support. Please note that JSON-RPC 1.0 is not supported.

  • Python 2.7, 3.3, 3.4, 3.5 and 3.6

  • Django 1.8, 1.9, 1.10 and 1.11

  • HTTP Basic Auth support

  • Custom authentication support

  • Automatic protocol detection based on the request’s Content-Type

  • High-level error handling based on exceptions

  • Multiple entry points, with specific methods and protocol attached

  • RPC Methods documentation generated automatically, based on docstrings

  • System introspection methods:

Quick start

  1. Install the library using pip:

pip install django-modern-rpc
  1. Add it to your Django applications, in settings.py:

INSTALLED_APPS = [
    #...
    'modernrpc',
    #...
]
  1. Declare an entry point, a view generating a correct RPC response to the incoming request:

# In myproject/rpc_app/urls.py
from django.conf.urls import url

from modernrpc.views import RPCEntryPoint

urlpatterns = [
    url(r'^rpc/', RPCEntryPoint.as_view()),
]
  1. Decorate the methods you want to provide via RPC calls:

# In myproject/rpc_app/rpc_methods.py
from modernrpc.core import rpc_method

@rpc_method
def add(a, b):
    return a + b
  1. Declare the list of python modules containing your RPC methods, in settings.py:

MODERNRPC_METHODS_MODULES = [
    'rpc_app.rpc_methods'
]

Now, you can call the method add from a client:

>>> from xmlrpc.client import ServerProxy
>>> client = ServerProxy('http://localhost:8000/rpc/')
>>> print(client.add(2, 3))
5

For more information, please read the full documentation.

Download files

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

Source Distribution

django-modern-rpc-0.5.0.tar.gz (20.6 kB view hashes)

Uploaded Source

Built Distribution

django_modern_rpc-0.5.0-py2.py3-none-any.whl (25.6 kB view hashes)

Uploaded Python 2 Python 3

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