An ASGI function for proxying to a backend over HTTP
Project description
asgi-proxy-lib
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.
CLI tool
You can try this module out like so:
python -m asgi_proxy https://datasette.io
This will start a server on port 8000 that proxies to https://datasette.io
.
Add -p PORT
to specify a different port, --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
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
Built Distribution
Hashes for asgi_proxy_lib-0.1a0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63808fbfa724ede5ba811b4e4717ffa1e00d749d36bb03e4ce993de042489dd3 |
|
MD5 | 65ff6ea1e107e2709bf85226a35b6df5 |
|
BLAKE2b-256 | 6deb6cb4dfacb1ab6db0e25f5a2821dc5d20a85eea8d6ecc9e5b65ae64a6a75b |