Lightweight CLI that wraps Python's http.server with automatic port-finding and shutdown.
Project description
quickhttp
quickhttp
is a lightweight CLI that wraps Python's http.server
with automatic port-finding and automatic shutdown after a configurable idle duration.
Features
- Automatically finds and uses an available port.
- Has a keep-alive time after which it will shut down automatically if no requests are received, in case you forget about it.
- More secure default of
127.0.0.1
(localhost
) instead of0.0.0.0
. - Easier to type and autocomplete than
python -m http.server
.
Installation
You can get quickhttp
from PyPI. I recommend using pipx
to manage Python command-line programs:
pipx install quickhttp
You can also install normally using regular pip
:
pip install quickhttp
Requires Python 3.6 or higher.
Development Version
To install the development version of this program, get it directly from GitHub.
pipx install git+https://github.com/jayqi/quickhttp.git
Documentation
quickhttp --help
Usage: quickhttp [OPTIONS] [DIRECTORY]
Lightweight CLI that wraps Python's `http.server` with automatic port-
finding and shutdown.
Arguments:
[DIRECTORY] Directory to serve. [default: .]
Options:
-t, --timeout TEXT Time to keep server alive for after most
recent request. Accepts time expressions
parsable by pytime parse, such as '10m' or
'10:00'. [default: 10m]
-b, --bind TEXT Address to bind server to. '127.0.0.1' (or
'localhost') will only be accessible from
this computer. '0.0.0.0' is all interfaces
(IP addresses) on this computer, meaning
that it can be accessible by other computers
at your IP address. [default: 127.0.0.1]
-p, --port INTEGER Port to use. If None (default), will
automatically search for an open port using
the other port-related options. If
specified, ignores other port-related
options.
--port-range-min INTEGER Minimum of range to search for an open port.
[default: 8000]
--port-range-max INTEGER Maximum of range to search for an open port.
[default: 8999]
--port-max-tries INTEGER Maximum number of ports to check. [default:
50]
--port-search-type [sequential|random]
Type of search to use. [default:
sequential]
--version Show version and exit.
--install-completion [bash|zsh|fish|powershell|pwsh]
Install completion for the specified shell.
--show-completion [bash|zsh|fish|powershell|pwsh]
Show completion for the specified shell, to
copy it or customize the installation.
--help Show this message and exit.
Why use quickhttp
?
python -m http.server
is a pain to type.quickhttp
is shorter and can autocomplete. (But you can still dopython -m quickhttp
too if you really want to.)- If you try starting
python -m http.server
and port 8000 is unavailable, you getOSError: [Errno 48] Address already in use
. Then you have to choose another port and try again.quickhttp
deals with ports automatically for you. quickhttp
will automatically shutdown after the keep-alive time expires. This defaults to 10 minutes. I often start up an HTTP server to look at something, then open a new tab to continue doing things, and then I forget about the server.python -m http.server
defaults to 0.0.0.0, which makes your server accessible to other people at your computer's IP address. This is a security vulnerability, but isn't necessarily obvious to people who just want to quickly serve some static files.
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
quickhttp-0.2.0.tar.gz
(7.2 kB
view details)
Built Distribution
File details
Details for the file quickhttp-0.2.0.tar.gz
.
File metadata
- Download URL: quickhttp-0.2.0.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c825787a025bfc2d346a7c390806e8dd589f3a55d2d16d2eda49989ff67be7d1 |
|
MD5 | 08f4feee73d0ffc3675d0bcf04f5b047 |
|
BLAKE2b-256 | 812cb9b68c1806d00ba3b8bcb27a2de79907280438f3c4a0f93bd8a3065785b2 |
File details
Details for the file quickhttp-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: quickhttp-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5be793aa84108ba021ba0ca88689f7c924ff0b675afde0c643d64b1f3c82a3e2 |
|
MD5 | 84d4f418704d071afb18440f4effcf7c |
|
BLAKE2b-256 | be0b3458c14fc04ef8e984e3e67cd18266354f5d0f245e2c66438595d1ca4869 |