Skip to main content

an extensible async background server

Project description

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.

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

bgserve-0.0.1.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

bgserve-0.0.1-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file bgserve-0.0.1.tar.gz.

File metadata

  • Download URL: bgserve-0.0.1.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.23.3

File hashes

Hashes for bgserve-0.0.1.tar.gz
Algorithm Hash digest
SHA256 68fac7e4e48ab53db35fc9d633a4aba252ee2b04de01b8357e77acef7edfc20d
MD5 195e9a707bbdf211a778e0bda5237643
BLAKE2b-256 b57ae4ccd4917a243967523a017a6ea243a2a96d4915333984ef5c2513210a6a

See more details on using hashes here.

File details

Details for the file bgserve-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: bgserve-0.0.1-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

Hashes for bgserve-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 452bbcd50d09e554e9479e54599d6381fd046347aa339bb0ab25274952288b75
MD5 46f0e439d03a8bff8bde22cadc801c0c
BLAKE2b-256 4e1ea4d742f5ca24ff347623cc1d1275501eb725874c7cae837dd83ba154c8e8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page