Skip to main content

bgserve

an extensible async background server for python

PyPI - Version PyPI - Python Version


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.

Metadata

Release files for bgserve 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bgserve 0.0.1
File Size Uploaded
bgserve-0.0.1.tar.gz 1.1 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for bgserve 0.0.1
File Interpreter ABI Platform
bgserve-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 1.2 MB

Release files / bgserve-0.0.1.tar.gz

Download URL bgserve-0.0.1.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
68fac7e4e48ab53db35fc9d633a4aba252ee2b04de01b8357e77acef7edfc20d
BLAKE2b-256 checksum
How to use checksums
b57ae4ccd4917a243967523a017a6ea243a2a96d4915333984ef5c2513210a6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.23.3

Release files / bgserve-0.0.1-py3-none-any.whl

Download URL bgserve-0.0.1-py3-none-any.whl
Size 11.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
452bbcd50d09e554e9479e54599d6381fd046347aa339bb0ab25274952288b75
BLAKE2b-256 checksum
How to use checksums
4e1ea4d742f5ca24ff347623cc1d1275501eb725874c7cae837dd83ba154c8e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.23.3

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page