Rest API - HTTP Status Codes
Consider this Python Flask code snippet for a REST API endpoint:
What will the client receive when requesting
from flask import Flask, jsonify
app = Flask(__name__)
@app.route('/data')
def get_data():
try:
result = 10 / 0 # This will cause an error
return jsonify({'result': result})
except Exception:
return jsonify({'error': 'Server error occurred'}), 500
if __name__ == '__main__':
app.run()What will the client receive when requesting
/data?