18 lines of node.js to accomplish something similar - I use something similar as a function in my node.js scripts to be able to send a generic error template based on the code that I pass back to the function.
var http = require('http');
http.createServer(function (request, response)
{
var statusCode = request.url.substr(1, 3);
response.writeHead(statusCode, { 'connection' : 'close', 'content-type' : 'text/html' });
response.write('<html>');
response.write('<head><title>' + statusCode + ' ' + http.STATUS_CODES[statusCode] + '</title></head>');
response.write('<body bgcolor="white">');
response.write('<center><h1>' + statusCode + ' ' + http.STATUS_CODES[statusCode] + '</h1></center>');
response.write(' '.repeat(512));
response.write('</body>');
response.end('</html>');
}).listen(8124, "0.0.0.0");
String.prototype.repeat = function(num)
{
return new Array(num++).join(this);
}