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"]
Note: the
Providerholds a weak reference to each resource it creates. This allows the provider to cleanup unused resources and prevent memory leaks. As an end user, you must hold a strong reference each resource returned by the provider so long as you'd like that endpoint to remain avaiable.
license
servir is distributed under the terms of the
MIT license.
Metadata
Release files for servir 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| servir-0.2.1.tar.gz | 11.6 kB | Without provenance | Details for servir-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| servir-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for servir-0.2.1-py3-none-any.whl |
Total release size: 23.2 kB
Release files / servir-0.2.1.tar.gz
| Download URL | servir-0.2.1.tar.gz |
|---|---|
| Size | 11.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f71f1d9015b661c7b1681565bcd3c6366e703f67202ba8ffcc195edb7ed3f105
|
|
BLAKE2b-256 checksum How to use checksums |
4d10b1a0852c7382b4e2ceba2a0d5bca2e1524309ae10fdb7f43d21732b68425
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.0.0 CPython/3.12.2
|
Release files / servir-0.2.1-py3-none-any.whl
| Download URL | servir-0.2.1-py3-none-any.whl |
|---|---|
| Size | 11.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e946e2bfc07aebf48913eeec3c69ca3aaf3da41bde5407cebfcca4881b9153d9
|
|
BLAKE2b-256 checksum How to use checksums |
986d16d4304c32be8fcc54802e216946af0dee815516eb2562dfca692c1b5ec4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.0.0 CPython/3.12.2
|
Security for servir 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.