Created
August 29, 2012 22:37
-
-
Save blakmatrix/3519790 to your computer and use it in GitHub Desktop.
custom http-server bin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hc