Python 的 http.server
$ python3 -m http.server
# Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
$ python3 -m http.server -d ~/Pictures/
# Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
- Bartosz Zaczyński(2023 年 5 月 22 日),《How to Launch an HTTP Server in One Line of Python Code》,Real Python 博文。2024 年 2 月 1 日查阅:https://realpython.com/python-http-server/
npm 上的 http-server
- http-server,
main分支,提交8f7fcb0。https://github.com/http-party/http-server
按需运行:
用 npx 可以直接运行,无需事先手动安装:
npx http-server [path] [options]
npm 上的 serve
- serve,
main分支,提交1ea55b1。https://github.com/vercel/serve
也可以全局安装这个包(需要 Node.js LTS 或更高版本):
npm install --global serve
serve folder-name/
# 用下面的命令查看所有可用选项:
serve --help