Skip to content

Instantly share code, notes, and snippets.

@johnvilsack
Created March 23, 2015 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnvilsack/d401a52c6671c2450985 to your computer and use it in GitHub Desktop.
Save johnvilsack/d401a52c6671c2450985 to your computer and use it in GitHub Desktop.
// Use the package, HTTP.
var http = require('http');
// In the package HTTP, execute createServer
http.createServer(function (req, res) {
// When createServer sees a request, shoot a header with a status 200 (this means OK) and tell it the next bit is text/plain
res.writeHead(200, {'Content-Type': 'text/plain'});
// This is the bits that go to the browser
res.end('Hello World\n');
})
//This tells http.createServer() to listen on port 1337, on address 127.0.0.1
.listen(1337, '127.0.0.1');
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