Skip to content

Instantly share code, notes, and snippets.

@TeeTeeHaa
Created February 7, 2013 10:37
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 TeeTeeHaa/4730166 to your computer and use it in GitHub Desktop.
Save TeeTeeHaa/4730166 to your computer and use it in GitHub Desktop.
// Example code straight from http://nodejs.org/ front page, slightly modified.
// Run with node.js (e.x. v.0.8.11 on Windows 7) and open website (once) with
// a browser which uses keep-alive connections (e.x. Firefox 18.0 on Windows 7).
// The program will not finish until the browser is closed :( because of the
// kept-alive connection. Not knowing that reason, how to debug the cause for
// the "not finishing" of the program?
var http = require('http');
var server = http.createServer(function(req, res)
{
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello World\n');
server.close(); // close server gracefully
}).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