A Python server implementaion of JSON-RPC 2.0 over HTTP
A Python server implementaion of JSON-RPC 2.0 over HTTP.
rufmich is an HTTP server for JSON-RPC 2.0. To make the JSON-RPC 2.0 work over HTTP, following specifications are added:
- The transport protocol is HTTP. The response for an notification is an HTTP response with status code 204 (No Response) and empty content. The HTTP requests must have the header
content-type: application/json, otherwise there will be an HTTP error 415 (Unsupported Media Type).
- A notification request will get an immediate response. Usually the server will start the procedure and return the response immediately (without having to wait for the procedure to finish). And there is no callback for the procedure, which means the client would not be aware of any errors.
- Method namespacing is supported (and recommended).
Notification is implemented using threading. A method without
id will be invoked in a new thread.
If multiple requests are sent in a batch, they will be processed concurrently by a thread pool.
pip install rufmich
Create a folder with following structure:
- <your_methods_workspace> - root root.py - <A> <A.py> - <B> <B.py> - <C> <C.py>
An example is:
- my_methods - root root.py - registration registration.py - by_email by_email.py
Note that there MUST BE a directory named root under your workspace folder.
Each namespace folder MUST HAVE a
.py file with the same name as the folder. The methods defined in those
.py files will be indexed according to the folder hierarchy.
- A method
root.pyis indexed to
- A method
by_email.pyin the above example is indexed to
from rufmich.server import RMServer server = RMServer(load_path=<your_methods_workspace>) server.run(port=<port>)
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.