Re:Httpstat.us: API for generating different HTTP codes.
by elliottcarlson on Tuesday February 15, 2011 @11:46AM
(#2221941)
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.
[ Parent
| on HN ]
Re:Httpstat.us: API for generating different HTTP codes.
by jsdalton on Tuesday February 15, 2011 @12:28PM
(#2222184)
Here's a little something similar I whipped up using Flask (Python):
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! :)]
Re:Httpstat.us: API for generating different HTTP codes.
by elliottcarlson on Tuesday February 15, 2011 @12:53PM
(#2222311)
Hah, indeed! Email me some time - x at sublim dot nl
Re:Httpstat.us: API for generating different HTTP codes.
by tatham on Monday February 21, 2011 @11:38PM
(#2248762)
This will get you 80% of the way there, but some status codes require certain response headers too. We return these too.
Re:Httpstat.us: API for generating different HTTP codes.
by johns on Tuesday February 22, 2011 @12:36AM
(#2248907)
signatures are discouraged here: http://ycombinator.com/newsguidelines.html