Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

asgi-proxy-lib

PyPI Changelog License

An ASGI function for proxying to a backend over HTTP

⚠️ Warning: this is an early alpha.

Installation

Install this library using pip:

pip install asgi-proxy-lib

Usage

This library provides a single ASGI function called asgi_proxy. You can use it like this:

from asgi_proxy import asgi_proxy

app = asgi_proxy("https://datasette.io")

Now app is an ASGI application that will proxy all incoming HTTP requests to the equivalent URL on https://datasette.io.

The function takes an optional second argument, log= - set this to a Python logger, or any object that has .info(msg) and .error(msg) methods, and the proxy will log information about each request it proxies.

It also takes a timeout= option, which defaults to None for no timeout. This can be set to a floating point value in seconds to enforce a timeout on requests that are being proxied.

CLI tool

You can try this module out like so:

python -m asgi_proxy https://datasette.io

You may need to pip install uvicorn first for this to work.

This will start a server on port 8000 that proxies to https://datasette.io.

Add -p PORT to specify a different port, --timeout 3 to set a timeout, --verbose to see debug logging, and --host 127.0.0.1 to listen on a different host (the default is 0.0.0.0).

Development

To contribute to this library, first checkout the code. Then create a new virtual environment:

cd asgi-proxy-lib
python -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

pytest

Release files for asgi-proxy-lib 0.2a0

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

Source distribution (sdist)

Source distribution for asgi-proxy-lib 0.2a0
File Size Uploaded
asgi_proxy_lib-0.2a0.tar.gz 8.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for asgi-proxy-lib 0.2a0
File Interpreter ABI Platform
asgi_proxy_lib-0.2a0-py3-none-any.whl Python 3 none any Details

Total release size: 16.5 kB

Release files / asgi_proxy_lib-0.2a0.tar.gz

Download URL asgi_proxy_lib-0.2a0.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b88f218751f8e25d43022485c3e7a040a0788d33f36a51775542e328c4160e86
BLAKE2b-256 checksum
How to use checksums
a4b2bb8a4cc83e86a983d69df4d4e1836948b944e1b12b2349993dd878c39005
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.13.0

Release files / asgi_proxy_lib-0.2a0-py3-none-any.whl

Download URL asgi_proxy_lib-0.2a0-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
658f938dc2d5cb39bbbf09e2c427ec96cfcfbb0e47bc9b3ee19ee3ec90f7e960
BLAKE2b-256 checksum
How to use checksums
8e52b51e5492b4256b889ddcfd7ec576c894bea024a80ffc22455ae350237c8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.13.0

Release history Release notifications | RSS feed

This release

0.2a0 This release

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