Created
January 6, 2014 22:53
-
-
Save nlf/8291357 to your computer and use it in GitHub Desktop.
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
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); |
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
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