Flask-JSONRPC-2.2.2
توضیحات
Adds JSONRPC support to Flask.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | Flask-JSONRPC-2.2.2 |
| نام | Flask-JSONRPC |
| نسخه کتابخانه | 2.2.2 |
| نگهدارنده | ['Cenobit Technologies Inc.'] |
| ایمیل نگهدارنده | ['hi@cenobit.es'] |
| نویسنده | Nycholas de Oliveira e Oliveira |
| ایمیل نویسنده | nycholas@gmail.com |
| آدرس صفحه اصلی | https://github.com/cenobites/flask-jsonrpc |
| آدرس اینترنتی | https://pypi.org/project/Flask-JSONRPC/ |
| مجوز | BSD-3-Clause |
[](https://travis-ci.org/cenobites/flask-jsonrpc)
[](https://coveralls.io/github/cenobites/flask-jsonrpc?branch=master)
[](https://flask-jsonrpc.readthedocs.io/en/latest/?badge=latest)
# 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](https://www.jsonrpc.org/specification "JSON-RPC 2.0") version.
* Support python 3.6 or later.
* The web browsable API.
* Run-time type checking functions defined with [PEP 484](https://www.python.org/dev/peps/pep-0484/ "PEP 484") argument (and return) type annotations.
* Extensive documentation, and great community support.
There is a live example API for testing purposes, [available here](http://flask-jsonrpc.herokuapp.com/api/browse "Web browsable API").
**Below:** *Screenshot from the browsable API*

### Adding Flask JSON-RPC to your application
1. Installation
```console
$ pip install Flask-JSONRPC
```
or
```console
$ git clone git://github.com/cenobites/flask-jsonrpc.git
$ cd flask-jsonrpc
$ python setup.py install
```
2. Getting Started
Create your application and initialize the Flask-JSONRPC.
```python
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.
```python
@jsonrpc.method("App.index")
def index() -> str:
return "Welcome to Flask JSON-RPC"
```
All code of example [run.py](https://github.com/cenobites/flask-jsonrpc/blob/master/run.py).
3. Running
```console
$ python run.py
* Running on http://0.0.0.0:5000/
```
4. Testing
```console
$ 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
* [http://docs.python.org/](http://docs.python.org/)
* [https://flask.palletsprojects.com/](https://flask.palletsprojects.com/)
* [http://www.jsonrpc.org/](http://www.jsonrpc.org/)
نیازمندی
| مقدار | نام |
|---|---|
| <3.0,>=1.0.0 | Flask |
| ==2.13.3 | typeguard |
| ==0.8.0 | typing-inspect |
| >=3.7.4 | typing |
| <3.10,>=3.7.4 | typing-extensions |
| >=4.3.0 | typing-extensions |
| <3.0,>=1.0.0 | Flask[async] |
| <3.0,>=1.0.0 | Flask[dotenv] |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.6 | Python |
نحوه نصب
نصب پکیج whl Flask-JSONRPC-2.2.2:
pip install Flask-JSONRPC-2.2.2.whl
نصب پکیج tar.gz Flask-JSONRPC-2.2.2:
pip install Flask-JSONRPC-2.2.2.tar.gz