Last active
March 12, 2017 20:30
-
-
Save tamg/14fa443d31a2c723aaa483df20d6cd92 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'); | |
//createServer takes a callback function, which gets invoked when a request occurs | |
//the callback function takes in request and response as parameters | |
//request (req) represents whats incoming | |
//response (res) represents the response we are building | |
http.createServer(function(req, res) { | |
//build the HTTP response | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.end('Hello World'); | |
}).listen(1337, '127.0.0.1' );//listen at port 1337 on the localhost | |
//we can now go to the browser at the localhost:1337 address and send a req | |
//we then get a 'Hello World' response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment