Skip to content

Instantly share code, notes, and snippets.

@blakmatrix
Created August 29, 2012 22:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blakmatrix/3519790 to your computer and use it in GitHub Desktop.
Save blakmatrix/3519790 to your computer and use it in GitHub Desktop.
custom http-server bin
#!/usr/bin/env node
var colors = require('colors'),
httpServer = require('../lib/http-server';
var port = 8080,
host = '0.0.0.0',
log = console.log;
var options = {
root: './app',
autoIndex: true,
cache: false
};
function onListening() {
log('Starting up http-server, serving '.yellow
+ server.root.cyan
+ ' on port: '.yellow
+ port.toString().cyan);
log('Hit CTRL-C to stop the server');
}
var server = httpServer.createServer(options);
server.listen(port, host, onListening);
if (process.platform !== 'win32') {
//
// Signal handlers don't work on Windows.
//
process.on('SIGINT', function () {
log('http-server stopped.'.red);
process.exit();
});
}
@kellsl
Copy link

kellsl commented Mar 4, 2023

Hc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment