Skip to content

Instantly share code, notes, and snippets.

@adamhalasz
Created January 23, 2013 17:45
Show Gist options
  • Save adamhalasz/4610894 to your computer and use it in GitHub Desktop.
Save adamhalasz/4610894 to your computer and use it in GitHub Desktop.
// 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