JsonRpcExtended
Description
A remote procedure call (RPC) framework based on JSON-RPC, extended to support alternative data formats and structures such as CSV, XML, binary and python calls.
Requirements
This package require:
- python3
- python3 Standard Library
- PegParser
Installation
Pip
python3 -m pip install JsonRpcExtended
Git
git clone "https://github.com/mauricelambert/JsonRpcExtended.git"
cd "JsonRpcExtended"
python3 -m pip install .
Wget
wget https://github.com/mauricelambert/JsonRpcExtended/archive/refs/heads/main.zip
unzip main.zip
cd JsonRpcExtended-main
python3 -m pip install .
cURL
curl -O https://github.com/mauricelambert/JsonRpcExtended/archive/refs/heads/main.zip
unzip main.zip
cd JsonRpcExtended-main
python3 -m pip install .
Usages
Python script
from JsonRpcExtended import *
from asyncio import run
server = AsyncServer("127.0.0.1", 8520)
run(server.start())
from JsonRpcExtended import *
import socket
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as server:
server.bind(("127.0.0.1", 8520))
server.listen()
conn, addr = server.accept()
with conn:
while True:
first_byte = conn.recv(1)
protocol = get_rpc_format(first_byte)
if FORMATS.BINARY == protocol:
data = conn.recv(1024)
elif FORMATS.JSON == protocol:
file = conn.makefile(mode='rwb')
data = file.readline()
elif FORMATS.CSV == protocol:
file = conn.makefile(mode='rwb')
data = file.readline() + file.readline()
elif FORMATS.XML == protocol:
raise NotImplementedError("XML parsing is not implemented yet")
response = loading_classes[protocol].handle_request_data(first_byte + data, conn.recv)
conn.sendall(response)
Links
License
Licensed under the GPL, version 3.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
jsonrpcextended-0.0.1.tar.gz
(30.3 kB
view details)
File details
Details for the file jsonrpcextended-0.0.1.tar.gz.
File metadata
- Download URL: jsonrpcextended-0.0.1.tar.gz
- Upload date:
- Size: 30.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16fbc401ea266a923d50e4fa7cf74424a39127fb8474b3384588372cf25a48ee
|
|
| MD5 |
acb383fdf2563de09f0cff9cbf640f61
|
|
| BLAKE2b-256 |
51cdd7c884bd1cc657fdd285931091779bfc9cc0170bc47dc5807ced7666d047
|