simple-http-file-server

v1.0.1
A simple HTTP static file server
http file server static

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

import createServer from 'simple-http-file-server'

createServer({
  root: '/path/to/directory',
  options: {
    ...
  }
}).listen('8888', () => console.log('Static file server listening at http://localhost:8888'))
npm i simple-http-file-server

Metadata

  • MIT
  • Whatever
  • catamphetamine
  • released 8/27/2018

Downloads

Maintainers