Adds JSONRPC support to Flask.
Project description
Flask JSON-RPC
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.8 or later.
- Experimental support to Mypyc, it compiles Python modules to C extensions.
- 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
Adding Flask JSON-RPC to your application
- Installation
$ pip install Flask-JSONRPC
or
$ git clone git://github.com/cenobites/flask-jsonrpc.git
$ cd flask-jsonrpc
$ python setup.py install
- Getting Started
Create your application and initialize the Flask-JSONRPC.
from flask import Flask
from flask_jsonrpc import JSONRPC
app = Flask("application")
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.
- Running
$ python run.py
* Running on http://0.0.0.0:5000/
- 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
Release history Release notifications | RSS feed
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-3.0.1.tar.gz
(762.7 kB
view details)
Built Distribution
File details
Details for the file Flask-JSONRPC-3.0.1.tar.gz
.
File metadata
- Download URL: Flask-JSONRPC-3.0.1.tar.gz
- Upload date:
- Size: 762.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 110295be39c6d6a110063630c050e3f8a4f79c50281898b3f1cb8a18fb3cb84a |
|
MD5 | 29ca67027f53912cb146d9305ea3e810 |
|
BLAKE2b-256 | 7e9d637a0620802e4c496bd5d48e3766c3a4fd6a03f815f9bcb183bc7a17a5bb |
File details
Details for the file Flask_JSONRPC-3.0.1-py2.py3-none-any.whl
.
File metadata
- Download URL: Flask_JSONRPC-3.0.1-py2.py3-none-any.whl
- Upload date:
- Size: 759.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7836fecbd4ff96c4e4cd1f1f8a56553f4f7452598c0ec652ad74f8ab75221e69 |
|
MD5 | ced2f858f8698e9d7037b1ac27089b99 |
|
BLAKE2b-256 | 2f1f51a5cf258fc59ee0b56483c0e467f8d07c3f4ca84fbae725d72669a5a038 |