@chenpu17/serve-here
v1.0.2
Published
A minimal CLI to serve static files from a directory over HTTP.
Maintainers
Readme
serve-here
Serve any local directory over HTTP with a single command.
用一条命令把任意本地目录通过 HTTP 暴露出去。
Features | 功能特点
- Instant static hosting for the current or specified directory.
立即托管当前目录或指定目录。 - Automatic
index.htmlsupport plus clean directory listings.
自动识别index.html,无首页时提供整洁的目录列表。 - Safe redirects for non-ASCII directory names (e.g. 中文路径).
支持中文等非 ASCII 路径的安全重定向。 - Directory rows include file size and last modified time.
列表项展示文件大小与最近修改时间。 - Works as a global install or
npxone-off.
支持全局安装或通过npx临时使用。
Installation | 安装
npm install -g @chenpu17/serve-hereOr run it ad‑hoc without installing globally:
或者临时使用:
npx @chenpu17/serve-hereUsage | 使用方式
serve-here [options] [directory]Installed globally, invoke via
serve-here; withnpx, runnpx @chenpu17/serve-here.
全局安装后直接使用serve-here;临时使用时运行npx @chenpu17/serve-here。directory: Directory to share; defaults to the current working directory.directory:要共享的目录,默认使用当前工作目录。-d, --dir <path>: Explicit directory override.-d, --dir <path>:显式指定要共享的目录。-p, --port <number>: Port to listen on (default8080).-p, --port <number>:设置监听端口(默认8080)。-H, --host <address>: Host/IP to bind (default0.0.0.0).-H, --host <address>:指定绑定的主机或 IP(默认0.0.0.0)。-h, --help: Show help.-h, --help:查看帮助信息。-V, --version: Print version.-V, --version:查看版本号。
After startup you’ll see the bound addresses in the terminal. Opening them in a browser displays your static files or a table view of the directory contents.
启动后终端会打印可访问的地址,浏览器打开即可查看静态文件;若目录中没有 index.html,将显示带有文件大小和修改时间的目录表格。
Development | 开发
npm install
npm startnpm start serves the current project directory so you can test quickly with a browser or curl.npm start 会把当前项目目录作为静态资源根目录,方便通过浏览器或 curl 快速验证。
