Quickly serve html files from node, php, or python
May 03, 2016
There will be times where you need to server some files through a browser and instead of setting a local instance of apache or MAMP, it might just be easier to use something in the command-line. I would recommend the node option as it seems to have a few more options. Mac ships with python and PHP which make those easier in some cases. Also, the PHP server will handle php files along with standard html.
Node
First install http-server
globally via npm.
npm install -g http-server
Then it’s as easy as
http-server
PHP
php -S <domain>:<port>
ie: php -s localhost:8000
Python
python -m SimpleHTTPServer
ie: python -m SimpleHTTPServer 8000