Skip to content

Instantly share code, notes, and snippets.

@nlf
Created January 6, 2014 22:53
Show Gist options
  • Save nlf/8291357 to your computer and use it in GitHub Desktop.
Save nlf/8291357 to your computer and use it in GitHub Desktop.
var http = require('http');
var s = http.createServer(function(req,res){
res.writeHead(200,{'content-type' : 'text/plain'});
res.write('hello');
setTimeout(function(){
res.end("world\n")
},2000);
});
s.listen(3000);
var Hapi = require('hapi');
var path = require('path');
module.exports.start = function (done) {
var server = Hapi.createServer('0.0.0.0', 3000);
server.start(function () {
console.log('Dating-With-Node Server started at: ' + server.info.port);
});
};
// If someone ran: "node server.js" then automatically start the server
if (path.basename(process.argv[1],'.js') == path.basename(__filename,'.js')) {
module.exports.start()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment