an extensible async background server
Project description
bgserve
an extensible async background server for python
table of contents
installation
pip install bgserve
usage
import pathlib
import requests
from bgserve 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
bgserve
is distributed under the terms of the MIT license.
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
bgserve-0.0.0.tar.gz
(1.1 MB
view details)
Built Distribution
bgserve-0.0.0-py3-none-any.whl
(11.2 kB
view details)
File details
Details for the file bgserve-0.0.0.tar.gz
.
File metadata
- Download URL: bgserve-0.0.0.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 | 911e44e5bd31a9a8a9b18e61640bed3ef4f86d56715c41453b87b8c0352979fa |
|
MD5 | dd52c71efdb9e54bfe301fe63ae8b463 |
|
BLAKE2b-256 | 7626c07cb99254176a2fff1acd4935c878321035a8be38ed1715feaaa896f938 |
File details
Details for the file bgserve-0.0.0-py3-none-any.whl
.
File metadata
- Download URL: bgserve-0.0.0-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 | d23fed5f35edd08ba3f67b794ff373b867b0d28aac62e7520e41cd73c022403c |
|
MD5 | c0a234072bbd3bc5c9a35f953099c9be |
|
BLAKE2b-256 | e77b5c7de4c604092ad3da32e59ddaa8cfa8e45d61afb22a5e672eec80bf58e2 |