How to use the http-server.HttpServer 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 5calls / 5calls / gulpfile.js View on Github external
gulp.task('html:serve', function (cb) {

  function alwaysServeIndex(req, res, next) {

    // Allow the development server to respond to URLs defined in the front end application.
    // Assume that any URL without a file extension can be handled by the client side code
    // and serve index.html (instead of 404).

    if(!(path.extname(req.url))) {
      req.url = "/";
    }
    next();
  }

  var server = new http_server.HttpServer({
    root: 'app/static',
    before: [connect_logger(), alwaysServeIndex]
  });
  server.listen(8000, function () {
    util.log('HTTP server started on port 8000');
    cb();
  });
});
github peter-mouland / react-lego / tests / config / test-server / test-server-entry.js View on Github external
require('../../../src/config/environment');
require('../../../src/app/polyfills/node-fetch');

const HttpServer = require('http-server').HttpServer;
let openServer = new HttpServer({ root: 'compiled'});

const startLocalServers = (done) => {
  openServer.listen(process.env.PORT, 'localhost', () => {
    console.log(`Server running on port ${process.env.PORT}`);
    done()
  });
};
const stopLocalServers = (done) => {
  console.log('Closing server...');
  openServer.close(done);
};


module.exports = {
  start: startLocalServers,
  stop: stopLocalServers
github wildhaber / gluebert / e2e / helper / server.helper.js View on Github external
async run() {
        this._server = new HttpServer({
            root: this._root,
            gzip: true,
        });

        return await this._server;
    }

http-server

A simple zero-configuration command-line http server

MIT
Latest version published 3 years ago

Package Health Score

82 / 100
Full package analysis