Skip to content

Instantly share code, notes, and snippets.

@psd
Created September 17, 2024 13:59
Show Gist options
  • Save psd/29834efeeb3d276b62a71f210989f1a9 to your computer and use it in GitHub Desktop.
Save psd/29834efeeb3d276b62a71f210989f1a9 to your computer and use it in GitHub Desktop.
Datasette redirection
$ python3.10 -m venv --prompt . .venv --clear --upgrade-deps && workon
Requirement already satisfied: pip in ./.venv/lib/python3.10/site-packages (22.2.2)
Collecting pip
Using cached pip-24.2-py3-none-any.whl (1.8 MB)
Requirement already satisfied: setuptools in ./.venv/lib/python3.10/site-packages (63.2.0)
Collecting setuptools
Using cached setuptools-75.1.0-py3-none-any.whl (1.2 MB)
Installing collected packages: setuptools, pip
Attempting uninstall: setuptools
Found existing installation: setuptools 63.2.0
Uninstalling setuptools-63.2.0:
Successfully uninstalled setuptools-63.2.0
Attempting uninstall: pip
Found existing installation: pip 22.2.2
Uninstalling pip-22.2.2:
Successfully uninstalled pip-22.2.2
Successfully installed pip-24.2 setuptools-75.1.0
(datasette-test) $ pip install datasette
Collecting datasette
Using cached datasette-0.64.8-py3-none-any.whl.metadata (7.7 kB)
Collecting asgiref>=3.2.10 (from datasette)
Using cached asgiref-3.8.1-py3-none-any.whl.metadata (9.3 kB)
Collecting click>=7.1.1 (from datasette)
Using cached click-8.1.7-py3-none-any.whl.metadata (3.0 kB)
Collecting click-default-group>=1.2.3 (from datasette)
Using cached click_default_group-1.2.4-py2.py3-none-any.whl.metadata (2.8 kB)
Collecting Jinja2>=2.10.3 (from datasette)
Using cached jinja2-3.1.4-py3-none-any.whl.metadata (2.6 kB)
Collecting hupper>=1.9 (from datasette)
Using cached hupper-1.12.1-py3-none-any.whl.metadata (3.7 kB)
Collecting httpx>=0.20 (from datasette)
Using cached httpx-0.27.2-py3-none-any.whl.metadata (7.1 kB)
Collecting pint>=0.9 (from datasette)
Using cached Pint-0.24.3-py3-none-any.whl.metadata (8.5 kB)
Collecting pluggy>=1.0 (from datasette)
Using cached pluggy-1.5.0-py3-none-any.whl.metadata (4.8 kB)
Collecting uvicorn>=0.11 (from datasette)
Using cached uvicorn-0.30.6-py3-none-any.whl.metadata (6.6 kB)
Collecting aiofiles>=0.4 (from datasette)
Using cached aiofiles-24.1.0-py3-none-any.whl.metadata (10 kB)
Collecting janus>=0.6.2 (from datasette)
Using cached janus-1.0.0-py3-none-any.whl.metadata (4.5 kB)
Collecting asgi-csrf>=0.9 (from datasette)
Using cached asgi_csrf-0.10-py3-none-any.whl.metadata (8.1 kB)
Collecting PyYAML>=5.3 (from datasette)
Using cached PyYAML-6.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (2.1 kB)
Collecting mergedeep>=1.1.1 (from datasette)
Using cached mergedeep-1.3.4-py3-none-any.whl.metadata (4.3 kB)
Collecting itsdangerous>=1.1 (from datasette)
Using cached itsdangerous-2.2.0-py3-none-any.whl.metadata (1.9 kB)
Requirement already satisfied: setuptools in ./.venv/lib/python3.10/site-packages (from datasette) (75.1.0)
Requirement already satisfied: pip in ./.venv/lib/python3.10/site-packages (from datasette) (24.2)
Collecting python-multipart (from asgi-csrf>=0.9->datasette)
Using cached python_multipart-0.0.9-py3-none-any.whl.metadata (2.5 kB)
Collecting typing-extensions>=4 (from asgiref>=3.2.10->datasette)
Using cached typing_extensions-4.12.2-py3-none-any.whl.metadata (3.0 kB)
Collecting anyio (from httpx>=0.20->datasette)
Using cached anyio-4.4.0-py3-none-any.whl.metadata (4.6 kB)
Collecting certifi (from httpx>=0.20->datasette)
Using cached certifi-2024.8.30-py3-none-any.whl.metadata (2.2 kB)
Collecting httpcore==1.* (from httpx>=0.20->datasette)
Using cached httpcore-1.0.5-py3-none-any.whl.metadata (20 kB)
Collecting idna (from httpx>=0.20->datasette)
Using cached idna-3.10-py3-none-any.whl.metadata (10 kB)
Collecting sniffio (from httpx>=0.20->datasette)
Using cached sniffio-1.3.1-py3-none-any.whl.metadata (3.9 kB)
Collecting h11<0.15,>=0.13 (from httpcore==1.*->httpx>=0.20->datasette)
Using cached h11-0.14.0-py3-none-any.whl.metadata (8.2 kB)
Collecting MarkupSafe>=2.0 (from Jinja2>=2.10.3->datasette)
Using cached MarkupSafe-2.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (3.0 kB)
Collecting appdirs>=1.4.4 (from pint>=0.9->datasette)
Using cached appdirs-1.4.4-py2.py3-none-any.whl.metadata (9.0 kB)
Collecting flexcache>=0.3 (from pint>=0.9->datasette)
Using cached flexcache-0.3-py3-none-any.whl.metadata (7.0 kB)
Collecting flexparser>=0.3 (from pint>=0.9->datasette)
Using cached flexparser-0.3.1-py3-none-any.whl.metadata (18 kB)
Collecting exceptiongroup>=1.0.2 (from anyio->httpx>=0.20->datasette)
Using cached exceptiongroup-1.2.2-py3-none-any.whl.metadata (6.6 kB)
Using cached datasette-0.64.8-py3-none-any.whl (232 kB)
Using cached aiofiles-24.1.0-py3-none-any.whl (15 kB)
Using cached asgi_csrf-0.10-py3-none-any.whl (11 kB)
Using cached asgiref-3.8.1-py3-none-any.whl (23 kB)
Using cached click-8.1.7-py3-none-any.whl (97 kB)
Using cached click_default_group-1.2.4-py2.py3-none-any.whl (4.1 kB)
Using cached httpx-0.27.2-py3-none-any.whl (76 kB)
Using cached httpcore-1.0.5-py3-none-any.whl (77 kB)
Using cached hupper-1.12.1-py3-none-any.whl (22 kB)
Using cached itsdangerous-2.2.0-py3-none-any.whl (16 kB)
Using cached janus-1.0.0-py3-none-any.whl (6.9 kB)
Using cached jinja2-3.1.4-py3-none-any.whl (133 kB)
Using cached mergedeep-1.3.4-py3-none-any.whl (6.4 kB)
Using cached Pint-0.24.3-py3-none-any.whl (301 kB)
Using cached pluggy-1.5.0-py3-none-any.whl (20 kB)
Using cached PyYAML-6.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (751 kB)
Using cached uvicorn-0.30.6-py3-none-any.whl (62 kB)
Using cached appdirs-1.4.4-py2.py3-none-any.whl (9.6 kB)
Using cached flexcache-0.3-py3-none-any.whl (13 kB)
Using cached flexparser-0.3.1-py3-none-any.whl (27 kB)
Using cached h11-0.14.0-py3-none-any.whl (58 kB)
Using cached MarkupSafe-2.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (25 kB)
Using cached typing_extensions-4.12.2-py3-none-any.whl (37 kB)
Using cached anyio-4.4.0-py3-none-any.whl (86 kB)
Using cached idna-3.10-py3-none-any.whl (70 kB)
Using cached sniffio-1.3.1-py3-none-any.whl (10 kB)
Using cached certifi-2024.8.30-py3-none-any.whl (167 kB)
Using cached python_multipart-0.0.9-py3-none-any.whl (22 kB)
Using cached exceptiongroup-1.2.2-py3-none-any.whl (16 kB)
Installing collected packages: appdirs, typing-extensions, sniffio, PyYAML, python-multipart, pluggy, mergedeep, MarkupSafe, itsdangerous, idna, hupper, h11, exceptiongroup, click, certifi, aiofiles, uvicorn, Jinja2, janus, httpcore, flexparser, flexcache, click-default-group, asgiref, asgi-csrf, anyio, pint, httpx, datasette
Successfully installed Jinja2-3.1.4 MarkupSafe-2.1.5 PyYAML-6.0.2 aiofiles-24.1.0 anyio-4.4.0 appdirs-1.4.4 asgi-csrf-0.10 asgiref-3.8.1 certifi-2024.8.30 click-8.1.7 click-default-group-1.2.4 datasette-0.64.8 exceptiongroup-1.2.2 flexcache-0.3 flexparser-0.3.1 h11-0.14.0 httpcore-1.0.5 httpx-0.27.2 hupper-1.12.1 idna-3.10 itsdangerous-2.2.0 janus-1.0.0 mergedeep-1.3.4 pint-0.24.3 pluggy-1.5.0 python-multipart-0.0.9 sniffio-1.3.1 typing-extensions-4.12.2 uvicorn-0.30.6
(datasette-test) $ wget https://congress-legislators.datasettes.com/legislators.db
2024-09-17 14:52:39 (5.16 MB/s) - ‘legislators.db’ saved [5468160]
(datasette-test) $ datasette legislators.db &
[1] 218529
(datasette-test) $ INFO: Started server process [218529]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:8001 (Press CTRL+C to quit)
(datasette-test) $ curl -vL 'http://127.0.0.1:8001//google.com/'
* Trying 127.0.0.1:8001...
* Connected to 127.0.0.1 (127.0.0.1) port 8001
> GET //google.com/ HTTP/1.1
> Host: 127.0.0.1:8001
> User-Agent: curl/8.5.0
> Accept: */*
>
INFO: 127.0.0.1:40532 - "GET //google.com/ HTTP/1.1" 302 Found
< HTTP/1.1 302 Found
< date: Tue, 17 Sep 2024 13:54:44 GMT
< server: uvicorn
< Location: //google.com
< content-type: text/html; charset=utf-8
< Transfer-Encoding: chunked
<
* Ignoring the response-body
* Connection #0 to host 127.0.0.1 left intact
* Clear auth, redirects to port from 8001 to 80
* Issue another request to this URL: 'http://google.com/'
* Host google.com:80 was resolved.
* IPv6: 2a00:1450:4009:815::200e
* IPv4: 142.250.178.14
* Trying 142.250.178.14:80...
* Connected to google.com (142.250.178.14) port 80
> GET / HTTP/1.1
> Host: google.com
> User-Agent: curl/8.5.0
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Location: http://www.google.com/
....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment