No project description provided
Project description
Description
JSON-RPC server based on fastapi:
Installation
pip install fastapi-jsonrpc
Usage
pip install uvicorn
import fastapi_jsonrpc as jsonrpc
from fastapi_jsonrpc import Param
app = jsonrpc.API()
api_v1 = jsonrpc.Entrypoint('/api/v1/jsonrpc')
class MyError(jsonrpc.BaseError):
CODE = 5000
MESSAGE = 'My error'
class DataModel(BaseModel):
details: str
@api_v1.method(errors=[MyError])
def echo(
data: str = Param(..., example='123'),
) -> str:
if data == 'error':
raise MyError(data={'details': 'error'})
return data
app.bind_entrypoint(api_v1)
if __name__ == '__main__':
import uvicorn
uvicorn.run(app, port=5000, debug=True, access_log=False)
Go to:
Development
Install poetry
Install dependencies
poetry updateInstall dephell
pip install dephellRegenerate setup.py
dephell deps convert
Changelog
[0.1.7]
Follow JSON-RPC specification in special cases:
Use aiojobs.Scheduler for batch requests
[0.1.6] Ability to write DataModel class in BaseError class scope
[0.1.5] Add error usage example to README.rst
[0.1.4] Add description to README.rst
[0.1.3] Fix README.rst
[0.1.2] Add usage example to README.rst
[0.1.1] README.rst
[0.1.0] Initial commit
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastapi-jsonrpc-0.1.7.tar.gz.
File metadata
- Download URL: fastapi-jsonrpc-0.1.7.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.17 CPython/3.7.3 Darwin/18.7.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51da4cddebb6759b35b45f281a75d764984311ce4392ba09c5bfe0877fbacef2
|
|
| MD5 |
f9bcdec09b7da3aebd918a23a3521657
|
|
| BLAKE2b-256 |
346a7db163f1313fdf8f17a0534fa6280e47962bf95ddb5c03c7ee63f9d05785
|
File details
Details for the file fastapi_jsonrpc-0.1.7-py3-none-any.whl.
File metadata
- Download URL: fastapi_jsonrpc-0.1.7-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.17 CPython/3.7.3 Darwin/18.7.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
961ed92c3130bd9e73cbd415e893f8f8b4e90f31b8d72ffa1e565850de8fea8a
|
|
| MD5 |
6b190861fb4359ffa6ccb16f816e7cb8
|
|
| BLAKE2b-256 |
0dbf37a2212e3de9660fa3fee3343fc5a603e0c215bd7ffccac06ce0325be47e
|