How to use the http-server/lib/http-server.createServer function in http-server

To help you get started, we’ve selected a few http-server examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github smontanari / code-forensics / scripts / webserver.js View on Github external
var dataPath = args.d || Path.resolve(__dirname, '../output');

var options = {
  root: webPath,
  cache: -1,
  showDir: true,
  autoIndex: true,
  before: [
    ecstatic({ root: jsPath, baseDir: '/js' }),
    ecstatic({ root: libPath, baseDir: '/lib' }),
    ecstatic({ root: dataPath, baseDir: '/data' }),
    server.newRouter(dataPath)
  ]
};

var webServer = httpServer.createServer(options);

/*eslint-disable no-console*/

webServer.listen(port, host, function() {
  console.log(ansi.yellow('Starting up http-server'));
  console.log(ansi.cyan('listening on ' + host + ':' + port));
  console.log(ansi.cyan('serving "/"     files from ' + webPath));
  console.log(ansi.cyan('serving "/js"   files from ' + jsPath));
  console.log(ansi.cyan('serving "/lib"  files from ' + libPath));
  console.log(ansi.cyan('serving "/data" files from ' + dataPath));
  console.log('Hit CTRL-C to stop the server');
});


['SIGINT', 'SIGTERM'].forEach(function(event) {
  process.on(event, function() {

http-server

A simple zero-configuration command-line http server

MIT
Latest version published 2 years ago

Package Health Score

77 / 100
Full package analysis