Simple HTTP server
Use
$ npm install simple-http-file-server --save
Running is easier via npx
.
$ npm install npx --save
npx
doesn't currently work on Windows so on Windows npx file-server
can be substituted with node node_modules/simple-http-file-server/bin/file-server
.
Running:
$ npx file-server <root-directory> <port>
Will serve files from current directory on port 8080
:
$ npx file-server . 8080
Will serve files from current directory on port 8080
, and if the requested file is not found then it will serve ./index.html
from the root directory with HTTP Status 200
:
$ npx file-server . 8080 "{\"default\": \"./index.html\"}"
Will serve files from current directory on port 8080
, and if the requested file is not found then it will serve ./404.html
from the root directory with HTTP Status 404
:
$ npx file-server . 8080 "{\"404\": \"./404.html\"}"
API