starlette-jsonrpc
Installation
pip install starlette-jsonrpc
Examples
Code:
import uvicorn
from starlette.applications import Starlette
from starlette_jsonrpc import dispatcher
from starlette_jsonrpc.endpoint import JSONRPCEndpoint
app = Starlette()
@dispatcher.add_method
async def subtract(params):
return params["x"] - params["y"]
@dispatcher.add_method(name="SubtractMethod")
async def seconds_subtract(params):
return params["x"] - params["y"]
@dispatcher.add_method
async def subtract_positional(x, y):
return x - y
app.mount("/api", JSONRPCEndpoint)
if __name__ == "__main__":
uvicorn.run(app)
Example of requests:
{
"jsonrpc": "2.0",
"method": "subtract",
"params": {"x": 42, "y": 23},
"id": "1"
}
{
"jsonrpc": "2.0",
"method": "SubtractMethod",
"params": {"x": 42, "y": 23},
"id": "1"
}
{
"jsonrpc": "2.0",
"method": "subtract_positional",
"params": [42, 23],
"id": "1"
}
Example of response:
{
"jsonrpc": "2.0",
"id": "1",
"result": 19
}
Contributing
Thank you for your interest in contributing. Everyone is welcome to take part in developting this package. Please fFollow contributing guide in CONTRIBUTING.md.
Support
If you like this project and find it useful and want to say "Thank you", please consider to buy me a coffee ;)
Metadata
Release files for starlette-jsonrpc 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| starlette-jsonrpc-0.2.0.tar.gz | 5.4 kB | Without provenance | Details for starlette-jsonrpc-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| starlette_jsonrpc-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for starlette_jsonrpc-0.2.0-py3-none-any.whl |
Total release size: 15.0 kB
Release files / starlette-jsonrpc-0.2.0.tar.gz
| Download URL | starlette-jsonrpc-0.2.0.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
800d517a3b0a89500793f2999b690c59fcd7134dfedf488bebc03f356bc09c15
|
|
BLAKE2b-256 checksum How to use checksums |
fe5ec1b4c28505701e918dce71f18f846bb93f96e6f21f751e4e01ff5bc55216
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0
|
Release files / starlette_jsonrpc-0.2.0-py3-none-any.whl
| Download URL | starlette_jsonrpc-0.2.0-py3-none-any.whl |
|---|---|
| Size | 9.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dcc34787df48f0e01d35a9de1267a5f7468bda0045393e1f5260c784c48864a5
|
|
BLAKE2b-256 checksum How to use checksums |
beda724e9c98f7410b070b091e4bbc2429d8b22e7813699568bdd171547bb403
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0
|
Security for starlette-jsonrpc 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.