Flask error handling: "Response object is not iterable"
As mentioned in the comments for the previous answer, that code isn't supported on Flask 0.8, and would require 0.9 or higher. If you need to support Flask 0.8, here is a compatible version that assigns the "status_code" instead:
@app.errorhandler(404)def not_found(error): resp = jsonify({'error':'not found'}) resp.status_code = 404 return resp