SIDEX: Simple Data Exchange server over HTTP
Project description
Simple Data Exchange server over HTTP
Overview
This package provides a function to launch a simple file server. Getting, putting, and deleting files on the server via the HTTP POST methods are available. The function setup_sidex()
returns a flask
instance. You can launch a simple file server by run()
.
from sidex import setup_sidex
target = '/path/to/directory'
app = setup_sidex(target)
app.run()
Otherwise, you can directly call sidex.server
.
$ python -m sidex.server /path/to/directory
By default, only retrieving files (get
) is available. The put
and delete
methods are enabled by setting a 'token' for each method. Of course, the get
function can be restricted by a token
.
The HTTP POST method is available to submit a request. Any request should contain the method
field, which should be one of get
, put
, and delete
. The token
field may be required in some cases. The followings are samples with curl
.
$ curl http://0.0.0.0:8080/path/to/file -F 'method=get'
$ curl http://0.0.0.0:8080/path/to/upload -F 'method=put' -F 'payload=@filename' -F 'token=foo'
$ curl http://0.0.0.0:8080/path/to/delete -F 'method=delete' -F 'token=bar'
The package provides a function, sidex_request()
, which is a wrapper function of requests.post()
. You can directly execute sidex.client
.
$ python -m sidex.client http://0.0.0.0:8080/path/to/file
$ python -m sidex.client http://0.0.0.0:8080/path/to/file --ping
$ python -m sidex.client http://0.0.0.0:8080/path/to/upload -f upload_file
$ python -m sidex.client http://0.0.0.0:8080/path/to/delete -d
Dependencies
The library is developed on Python 3.9.9. The following packages are required:
flask>=2.0
requests>=2.27
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for sidex-1.2-py3-none-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e5b91393531d636d858814db2324a4e277a8f95aac8426ab9016ea7f401f2e7 |
|
MD5 | 6c464d7f42b967bd8f716b907dadb1a8 |
|
BLAKE2b-256 | f6829a4a83233e5a8cb170c8acb2613158e59f0e58a2b4cf9d3eaf2b68dbf81c |