Skip to content
A simple http file server
JavaScript HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
src
views
.babelrc
.gitignore
.prettierrc
LICENSE
README.md
package.json
yarn.lock

README.md

httpsrv

A simple http file server

Usage

npm i -g httpsrv #yarn global add httpsrv
httpsrv .

then open localhost:3333

Options

Usage: httpsrv <basedir>

Options:
  --help              Show help                                        [boolean]
  --version           Show version number                              [boolean]
  --port, -p          Port to listen                    [number] [default: 3333]
  --log, -l           Enable logger                                    [boolean]
  --indexhtml, -i     Try to show index.html if exists                 [boolean]
  --instantclick, -x  disable instantclick.js in directory page
                                                       [boolean] [default: true]
  --cors, -c          Access-Control-Allow-Origin header                [string]
  --fallback, -f      A file will be send when 404, useful in SPA (will disable
                      directory listing page)                           [string]

Examples:
  httpsrv . -p 8888  Start server on port 8888

API (cli.js)

#!/usr/bin/env node
const createServer = require('./index') //require('httpsrv')
const { _: [basedir], port, log, cors, fallback, indexhtml } = require('yargs')
  .usage('Usage: $0 <basedir>') //many things....

//options same as cli options, return an express app
const app=createServer({ basedir, log, cors, fallback, indexhtml , instantclick })
app.listen(port, _ => console.log(`listen on *:${port}`))
You can’t perform that action at this time.