Skip to main content

Adds JSONRPC support to Flask.

Project description

Build Status Coverage Status

Flask JSON-RPC

A basic JSON-RPC implementation for your Flask-powered sites.

Some reasons you might want to use:

  • Simple, powerful, flexible and pythonic API.
  • Support JSON-RPC 2.0 version.
  • Support python 3.6 or later.
  • The web browsable API.
  • Run-time type checking functions defined with PEP 484 argument (and return) type annotations.
  • Extensive documentation, and great community support.

There is a live example API for testing purposes, available here.

Below: Screenshot from the browsable API

Web browsable API

Adding Flask JSON-RPC to your application

  1. Installation
    $ pip install Flask-JSONRPC

or

    $ git clone git://github.com/cenobites/flask-jsonrpc.git
    $ cd flask-jsonrpc
    $ python setup.py install
  1. Getting Started

Create your application and initialize the Flask-JSONRPC.

    from flask import Flask
    from flask_jsonrpc import JSONRPC

    app = Flask(__name__)
    jsonrpc = JSONRPC(app, '/api', enable_web_browsable_api=True)

Write JSON-RPC methods.

    @jsonrpc.method('App.index')
    def index() -> str:
        return 'Welcome to Flask JSON-RPC'

All code of example run.py.

  1. Running
    $ python run.py
     * Running on http://0.0.0.0:5000/
  1. Testing
    $ curl -i -X POST \
       -H "Content-Type: application/json; indent=4" \
       -d '{
        "jsonrpc": "2.0",
        "method": "App.index",
        "params": {},
        "id": "1"
    }' http://localhost:5000/api
    HTTP/1.0 200 OK
    Content-Type: application/json
    Content-Length: 77
    Server: Werkzeug/0.8.3 Python/2.7.3
    Date: Fri, 14 Dec 2012 19:26:56 GMT

    {
      "jsonrpc": "2.0",
      "id": "1",
      "result": "Welcome to Flask JSON-RPC"
    }

References

Project details


Download files

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

Source Distribution

Flask-JSONRPC-1.0.2.tar.gz (690.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Flask_JSONRPC-1.0.2-py3-none-any.whl (719.2 kB view details)

Uploaded Python 3

File details

Details for the file Flask-JSONRPC-1.0.2.tar.gz.

File metadata

  • Download URL: Flask-JSONRPC-1.0.2.tar.gz
  • Upload date:
  • Size: 690.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for Flask-JSONRPC-1.0.2.tar.gz
Algorithm Hash digest
SHA256 1d490e9cf109e1dbf0a02a84dd02edeafb847100a1a4b7a6c6a97bd23d22846d
MD5 7774c490b031e499978ead956cdf5678
BLAKE2b-256 6b0ab5bfcc6cbfd0563e090c2dce54ba00013e770c7c8741dc9a62f159ecd898

See more details on using hashes here.

File details

Details for the file Flask_JSONRPC-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: Flask_JSONRPC-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 719.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for Flask_JSONRPC-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2136907fc562a26f3b29b7aa1ac336aabb72cf74a9f34e36ddda60998fe62ef7
MD5 409bd900e0baadc03b033ff392b35fc8
BLAKE2b-256 75a665a92310abb2183b253774df0e27ff61253dc1434134b9ccf999a71a8feb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page