Skip to main content

an extensible async background server

Project description

servir

PyPI - Version PyPI - Python Version

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.4.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

servir-0.0.4-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file servir-0.0.4.tar.gz.

File metadata

  • Download URL: servir-0.0.4.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for servir-0.0.4.tar.gz
Algorithm Hash digest
SHA256 90229f421f572bf4beb84533e95e642b1aaf173fbe01d8e6e07f73837c09db51
MD5 e16985286be830d04f864d744a509f94
BLAKE2b-256 132ffa3e9104e39489563fdbe217bb1e74037f2345bdd2f0df0b28278f6ff311

See more details on using hashes here.

File details

Details for the file servir-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: servir-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for servir-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 99495cea9acd1f1dc526a9a5e098733daefa665bdaf5d9bd9a7098480a3f01f8
MD5 ba0edd694e8c0f99d66d66c38f41341b
BLAKE2b-256 703ed9c6982386d7a6a68a6956fd830fb0d338572180615c91da7f017fddb7bd

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