by elliottcarlson · 15y ago · 0 comments
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);
} import time
from flask import Flask, make_response, request
app = Flask(__name__)
@app.route('/<int:status_code>')
def return_status(status_code):
response = make_response()
response.status_code = status_code
response.data = response.status
sleep = request.args.get('sleep', None)
if sleep is not None:
time.sleep(int(sleep))
return response
if __name__ == '__main__':
app.run(debug=True)
With a handy little feature, a "sleep" query string param that'll delay the response for the given number of seconds, which I've used to test how a client handles latency etc.[BTW, looks like you're the Elliot Carlson I used to work with way back when. Hope life is treating you well these days! :)]