在 macOS 上使用一个终端命令启动 Web 服务器

Avatar of Chris Coyier
Chris Coyier

我本周已经三次搜索过这个命令了,所以我想我最好确保自己有一个副本。

Python 2

python -m SimpleHTTPServer 8000

在终端中导航到项目目录并执行该命令。然后 https://#:8000 将提供该目录的服务(例如,它的 `index.html` 文件)。

Python 3

python3 -m http.server --cgi 8080

PHP

php -S localhost:2222

npm

npm i -g serve
serve