Skip to content

Instantly share code, notes, and snippets.

@rsbohn
Created February 9, 2012 16:14
Show Gist options
  • Save rsbohn/1780867 to your computer and use it in GitHub Desktop.
Save rsbohn/1780867 to your computer and use it in GitHub Desktop.
When will the world end? jpocalypse.herokuapp.com
var http = require("http");
var port = process.env.PORT || 9944;
var somany = Math.round(port/10+10);
console.log("server.js on "+port);
console.log("The world will end in "+somany+" days.")
http.createServer(function(request, response) {
var status = 200;
if (somany < 1) {status = 410;}
response.writeHead(status, {"Content-Type": "text/plain"});
if (somany > 0) {
response.write("The world will end in "+somany+" days.\n");
} else {
response.write("The world has ended. Sorry.\n");
}
response.end();
somany--;
console.log("Now only "+somany+" days left.\n");
}).listen(port);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment