Serve a local directory via HTTP/HTTPS with NodeJS

Originally posted on 2022-02-03

This is a better option than the Python web server I’ve used before since it has features to support seeking inside of files which is very useful if you’re serving up local video files.

Need to serve a local directory via HTTP from a web server? Do this one-time setup:

sudo npm install -g http-server
hash -r

And then navigate to your directory in a terminal and run:

http-server

Need to serve a local directory via HTTP from a web server on a specific port?

http-server -p PORT