A very simple RPC-like library to make writing Pyodide applications easier. At the core of the library is a simple App + Decorator based approach inspired by Flask.
Project description
prpc-python - Pyodide Remote Procedure Calls - Python Server
Provides server-side bindings for prpc API.
To expose a python function as a prpc method you first create
a prpc RpcApp and then decorate your function with @app.call.
Create a file called myapp.py and add the following code:
# myapp.py
from prpc_python import RpcApp
app = RpcApp("Sample App")
@app.call
def hello() :
return "World"
Discovering your API
You can now discover your API using the prpc command line tool. To do this
you either have to specify the plugin ID of your app or "publish" the
plugin using the Python plugin discovery approach.
The ID of your plugin is the name of the module containing
your RpcApp instance plus the name of the instance, e.g.
myapp:app for the example above.
You can now use the command line tool to discover your API:
prpc commands -a myapp:app
and you can even call your function from the command line:
prpc run -a myapp:app hello
Publishing
You don't always want to have to specify the plugin ID of your app. You can
use the approach described in the metadata section of the packaging
spec to publish your plugin. If you have a pyproject.toml file, then add
the following section:
[tool.poetry.plugins."prpc_python"]
myapp = "myapp:app"
If your plugin is the only one in your installed dependencies, then it will
be automatically chosen, and you can omit the -a myapp:app argument.
Files
prpc also supports file transfers. If you receive a file from the remote
endpoint, you will receive a prpc_python.RemoteFile object. This object
has a standard read method, so you can use it as a file-like object.
It may also have filename, size and content_type attributes but it
depends on the source of the file whether these are available.
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 prpc_python-0.9.1.tar.gz.
File metadata
- Download URL: prpc_python-0.9.1.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.8.12 Darwin/21.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0187b46169ba088eb6d377b112897581881c746f4fa192e78786b005bb6b9ae5
|
|
| MD5 |
610a74f5bd5819fd9e9e8810e6577818
|
|
| BLAKE2b-256 |
de3350bb5c6e72d0b86b4a8ae6f7cc0e3f63ac56f6f363907a53f1680da0da07
|
File details
Details for the file prpc_python-0.9.1-py3-none-any.whl.
File metadata
- Download URL: prpc_python-0.9.1-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.8.12 Darwin/21.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ea277640d5f4b10fa922a186cc9fcb5016c378df5ddee98e7e09af87fc2cb7f
|
|
| MD5 |
9473be5119dd763e69f3f8052433655a
|
|
| BLAKE2b-256 |
c0662d919747cfcc1340797e1034cda509235f9b97ebbc14e123badc870b2cc8
|