Is there Node.js ready-to-use tool (installed with npm
), that would help me expose folder content as file server over HTTP.
Example, if I have
http-server
, hs
- linknpm i -g http-server // install
hs C:\repos // run with one line?? FTW!!
serve
by ZEIT.co - linknpm i -g serve // install
serve C:\repos // run with one line?? FTW!!
Following are available options, if this is what helps you decide.
C:\Users\Qwerty>http-server --help usage: http-server [path] [options] options: -p Port to use [8080] -a Address to use [0.0.0.0] -d Show directory listings [true] -i Display autoIndex [true] -g --gzip Serve gzip files when possible [false] -e --ext Default file extension if none supplied [none] -s --silent Suppress log messages from output --cors[=headers] Enable CORS via the "Access-Control-Allow-Origin" header Optionally provide CORS headers list separated by commas -o [path] Open browser window after starting the server -c Cache time (max-age) in seconds [3600], e.g. -c10 for 10 seconds. To disable caching, use -c-1. -U --utc Use UTC time format in log messages. -P --proxy Fallback proxy if the request cannot be resolved. e.g.: http://someurl.com -S --ssl Enable https. -C --cert Path to ssl cert file (default: cert.pem). -K --key Path to ssl key file (default: key.pem). -r --robots Respond to /robots.txt [User-agent: *\nDisallow: /] -h --help Print this list and exit.
C:\Users\Qwerty>serve --help Usage: serve.js [options] [command] Commands: help Display help Options: -a, --auth Serve behind basic auth -c, --cache Time in milliseconds for caching files in the browser -n, --clipless Don't copy address to clipboard (disabled by default) -C, --cors Setup * CORS headers to allow requests from any origin (disabled by default) -h, --help Output usage information -i, --ignore Files and directories to ignore -o, --open Open local address in browser (disabled by default) -p, --port Port to listen on (defaults to 5000) -S, --silent Don't log anything to the console -s, --single Serve single page applications (sets `-c` to 1 day) -t, --treeless Don't display statics tree (disabled by default) -u, --unzipped Disable GZIP compression -v, --version Output the version number
If you need to watch for changes, see hostr, credit Henry Tseng's answer