Complete the code to import the Flask class.
from flask import [1] app = [1](__name__)
The Flask class is imported from the flask module to create the app instance.
Complete the code to get JSON data from a POST request.
from flask import request @app.route('/data', methods=['POST']) def data(): data = request.[1] return 'Received'
Use request.json to access JSON data sent in the request body.
Fix the error in the code to validate a required JSON field 'name'.
from flask import request, abort @app.route('/submit', methods=['POST']) def submit(): data = request.json if not data or '[1]' not in data: abort(400, 'Missing name') return 'OK'
The code checks if the key 'name' is present in the JSON data to validate the request.
Fill both blanks to extract 'age' from JSON and check if it is an integer.
data = request.json age = data.get([1]) if not isinstance(age, [2]): abort(400, 'Age must be an integer')
Use data.get('age') to get the age value and check if it is an int.
Fill all three blanks to return a JSON error response with status 400.
from flask import jsonify, abort @app.route('/check', methods=['POST']) def check(): data = request.json if not data or 'email' not in data: return jsonify([1]: [2]), [3] return 'Valid'
Return a JSON object with key 'error' and message 'Missing email' and HTTP status 400.
