Complete the code to return a custom status code 202 in a Flask route.
from flask import Flask, jsonify app = Flask(__name__) @app.route('/') def home(): return jsonify(message='Accepted'), [1]
The status code 202 means the request has been accepted for processing.
Complete the code to define a Flask response with a custom status code 418 (I'm a teapot).
from flask import Flask, Response app = Flask(__name__) @app.route('/teapot') def teapot(): return Response('I am a teapot', status=[1])
Status code 418 is a playful HTTP code meaning "I'm a teapot".
Fix the error in the code to correctly return a JSON response with custom status code 429 (Too Many Requests).
from flask import Flask, jsonify app = Flask(__name__) @app.route('/limit') def limit(): return jsonify(error='Too many requests'), [1]
429 is the correct status code for "Too Many Requests".
Fill both blanks to create a Flask route that returns a JSON message with status code 451 (Unavailable For Legal Reasons).
from flask import Flask, jsonify app = Flask(__name__) @app.route('/legal') def legal(): return jsonify([1]='Unavailable for legal reasons'), [2]
The key 'message' holds the text, and 451 is the status code for legal restrictions.
Fill all three blanks to return a Flask JSON response with a custom status code 207 (Multi-Status) and a custom key.
from flask import Flask, jsonify app = Flask(__name__) @app.route('/multi') def multi(): return jsonify([1]=[2]), [3]
The JSON key is 'status' with value 'multi-status', and 207 is the custom status code.