Skip to main content

Lightweight CLI that wraps Python's http.server with automatic port-finding and shutdown.

Project description

quickhttp

tests codecov PyPI

quickhttp is a lightweight CLI that wraps Python's http.server with automatic port-finding and automatic shutdown after a certain duration.

Features

  • Automatically finds and uses an available port.
  • Has a keep-alive time and shuts down automatically, in case you forget about it.
  • More secure default of 127.0.0.1 (localhost) instead of 0.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, --time TEXT                 Time to keep server alive for. Accepts time
                                  expressions parsable by pytimeparse, 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 do pythom -m quickhttp too if you really want to.)
  • If you try starting python -m http.server and port 8000 is unavailable, you get OSError: [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 will start up an HTTP server to look at something, and then I 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 obvious to people who don't know about 0.0.0.0 and 127.0.0.1.

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

Uploaded Source

Built Distribution

quickhttp-0.1.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file quickhttp-0.1.0.tar.gz.

File metadata

  • Download URL: quickhttp-0.1.0.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.4

File hashes

Hashes for quickhttp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 22c72a4b92e37cff5ce41164e311f86fc154f781cd003424f8ff2256a7f2908c
MD5 e34b42a71d9f9217ff41428a4f2317b2
BLAKE2b-256 5843047cc1751a0f877e12cea17d5d026b44bdea7f5003aed5f68fc16a27bdfc

See more details on using hashes here.

File details

Details for the file quickhttp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: quickhttp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.4

File hashes

Hashes for quickhttp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f17f7c351f96f1435bcbf6fd8374c8978dda29f460b2ef321e6cedcbe3fe3ab3
MD5 3e576e50d06b6e025c511f0936c242d5
BLAKE2b-256 a1ac318685ceee32817d6d0dcf85b90ea54b71110d41e63ba98664d76eb71046

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