Skip to content

Instantly share code, notes, and snippets.

@ahsankhatri
Last active January 11, 2016 10:00
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 ahsankhatri/fb92c69139f9f503c679 to your computer and use it in GitHub Desktop.
Save ahsankhatri/fb92c69139f9f503c679 to your computer and use it in GitHub Desktop.
HTTP Code status as a service
var http = require('http');
http.createServer(function (request, response) {
var status = request.url.substr(1);
if ( ! http.STATUS_CODES[status]) {
status = '404';
}
response.writeHead(status, { 'Content-Type': 'text/plain' });
response.end(http.STATUS_CODES[status]);
}).listen(process.env.PORT || 5000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment