轻量级 CLI,使用自动端口查找和关闭来包装 Python 的 http.server。
项目描述
快速http
quickhttp是一个轻量级的 CLI,它http.server使用自动端口查找和可配置的空闲时间后自动关闭来包装 Python。
特征
- 自动查找并使用可用端口。
- 有一个保持活动时间,如果没有收到请求,它将自动关闭,以防你忘记它。
127.0.0.1(localhost) 而不是0.0.0.0.- 比 . 更容易键入和自动完成
python -m http.server。
安装
您可以quickhttp从PyPI获得。我推荐使用pipx来管理 Python 命令行程序:
pipx install quickhttp
您也可以使用常规正常安装pip:
pip install quickhttp
需要 Python 3.6 或更高版本。
开发版
要安装此程序的开发版本,请直接从 GitHub 获取。
pipx install git+https://github.com/jayqi/quickhttp.git
文档
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.
为什么使用quickhttp?
python -m http.server打字很痛苦。quickhttp更短并且可以自动完成。(但python -m quickhttp如果你真的愿意,你仍然可以这样做。)- 如果您尝试启动
python -m http.server并且端口 8000 不可用,您将获得OSError: [Errno 48] Address already in use. 然后您必须选择另一个端口并重试。quickhttp自动为您处理端口。 quickhttp保活时间到期后会自动关机。这默认为 10 分钟。我经常启动一个 HTTP 服务器来查看一些东西,然后打开一个新选项卡继续做事,然后我就忘记了服务器。python -m http.server默认为 0.0.0.0,这可能使您的计算机 IP 地址上的其他人可以访问您的服务器。这是一个安全漏洞,但对于只想快速提供一些静态文件的人来说并不一定很明显。
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
quickhttp-1.0.0.tar.gz
(7.5 kB
查看哈希)
内置分布
quickhttp-1.0.0-py3-none-any.whl
(8.4 kB
查看哈希)