npm.io
0.5.3 • Published 1 year agoCLI

static-handler

Licence
ISC
Version
0.5.3
Deps
0
Size
60 kB
Vulns
0
Weekly
0
Stars
11

static-handler

A very simple static files handler, useful for testing, debugging purpose, or whenever a very basic static file server is needed as fallback/resource.

# as CLI
npx static-handler --help
// as utility
const staticHandler = require('static-handler');

const handled = staticHandler(__dirname);

require('http').createServer((req, res) => {
  // handled as static content, returns true
  if (handled(req, res))
    return;

  // do anything else
}).listen(8080);

Keywords