Giter Site home page Giter Site logo

dansan / django-modern-rpc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alorence/django-modern-rpc

0.0 2.0 0.0 515 KB

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

Home Page: http://django-modern-rpc.rtfd.io

License: MIT License

Python 97.84% HTML 2.16%

django-modern-rpc's Introduction

django-modern-rpc

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

Description

Django-modern-rpc provides a simple solution to implement a remote procedure call (RPC) server as part of your Django project. It supports all major Django and Python versions.

Project's main features are:

  • Simple and pythonic API
  • Python 2.7, 3.3, 3.4, 3.5 and 3.6
  • Django 1.8 to 2.0
  • XML-RPC and JSON-RPC 2.0 support (JSON-RPC 1.0 not supported)
  • HTTP Basic Auth support
  • Custom authentication support
  • Automatic protocol detection based on request's Content-Type header
  • High-level error management 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. Use pip to install the package in your environment:

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

    INSTALLED_APPS = [
        ...
        'modernrpc',
    ]
    
  3. Declare an entry point, a view generating correct RPC responses to incoming requests:

    # In myproject/rpc_app/urls.py
    from django.conf.urls import url
    
    from modernrpc.views import RPCEntryPoint
    
    urlpatterns = [
        url(r'^rpc/', RPCEntryPoint.as_view()),
    ]
    
  4. Use @rpc_method to register a global function in django-modern-rpc registry:

    # In myproject/rpc_app/rpc_methods.py
    from modernrpc.core import rpc_method
    
    @rpc_method
    def add(a, b):
        return a + b
    
  5. 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.

django-modern-rpc's People

Contributors

adamdonahue avatar alorence avatar dansan avatar sergio-bershadsky avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.