an extensible async background server
Project description
servir
an extensible async background server for python
table of contents
installation
pip install servir
usage
import pathlib
import requests
from servir import Provider
# create a provider
provider = Provider()
### File (supports range requests)
path = pathlib.Path("hello.txt")
path.write_text("hello, world")
file_resource = provider.create(path)
response = requests.get(file_resource.url)
assert response.text == "hello, world"
assert "text/plain" in response.headers["Content-Type"]
### Directory (supports range requests)
root = pathlib.Path("data_dir")
root.mkdir()
(root / "hello.txt").write_text("hello, world")
dir_resource = provider.create(root)
response = requests.get(file_resource.url + "/hello.txt")
assert response.text == "hello, world"
assert "text/plain" in response.headers["Content-Type"]
### In-memory
data = "a,b,c,\n1,2,3,\n4,5,6"
content_resource = provider.create(data, extension=".csv")
response = requests.get(content_resource.url)
assert response.text == data
assert "text/csv" in response.headers["Content-Type"]
license
servir
is distributed under the terms of the MIT license.
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
servir-0.0.3.tar.gz
(1.1 MB
view details)
Built Distribution
servir-0.0.3-py3-none-any.whl
(11.2 kB
view details)
File details
Details for the file servir-0.0.3.tar.gz
.
File metadata
- Download URL: servir-0.0.3.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.23.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28e93e2adbf5f55adecdbb025f3319fc8bfdcb97518b5e82a9ccb627de6e7e57 |
|
MD5 | 58938aa873494ebb841abddd6eb43407 |
|
BLAKE2b-256 | 3cdabfd9792ef71ac22ec0e1a065e0db06b860b67eef20aa82a99f1fd0e84c39 |
File details
Details for the file servir-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: servir-0.0.3-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.23.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3789510a84d472525dcc7d4de42654dab385003d0c0483e524db2a7147d68482 |
|
MD5 | b17607fb0d13368518792ba9bd61cf60 |
|
BLAKE2b-256 | 69c54def233e51ed4acb533e37d7245331ad9616ba2a2180b6a5ef68f3ad4086 |