Created
February 9, 2012 16:14
-
-
Save rsbohn/1780867 to your computer and use it in GitHub Desktop.
When will the world end? jpocalypse.herokuapp.com
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
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