Created
January 23, 2013 17:45
-
-
Save adamhalasz/4610894 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
// Setup | |
var http = require('http'); // require http module | |
var port = 80; // http port | |
var host = '127.0.0.1' // localhost | |
// This function will be called when a request arrives from a client | |
function onRequest(request, response) { | |
response.writeHead(200, {'Content-Type': 'text/plain'}); // headers | |
response.end('Hello World'); // end response | |
} | |
// Create the http server which will pass requests to `onRequest` | |
var server = http.createServer(onRequest) | |
server.listen(port, host); | |
// Log that the server is running | |
console.log('Server running at http://127.0.0.1:1337/'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment