simple-http-file-server

1.0.1 • Public • Published

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'))

Readme

Keywords

Package Sidebar

Install

npm i simple-http-file-server

Weekly Downloads

6

Version

1.0.1

License

MIT

Unpacked Size

37.2 kB

Total Files

4

Last publish

Collaborators

  • catamphetamine