Complete the code to set the Content-Type header to JSON.
headers = {"Content-Type": "[1]"}The Content-Type header must be set to application/json to indicate JSON data.
Complete the code to convert a Python dictionary to a JSON string.
import json json_data = json.[1](data)
load or loads which are for reading JSON.The json.dumps() function converts a Python object to a JSON string.
Fix the error in the code to parse JSON from a string.
import json parsed = json.[1](json_string)
load which reads from a file, not a string.The json.loads() function parses a JSON string into a Python object.
Fill both blanks to create a JSON response with status code 200.
response = [1](json.dumps(data), [2]=200, headers=headers)
jsonify which returns a response but does not accept status code like this.make_response creates a response object. The status code is set with status.
Fill all three blanks to extract a value from JSON request data.
from flask import request json_data = request.[1] value = json_data.get([2], [3])
args which is for query parameters, not JSON body.Use request.json to get JSON data. Use get("key", None) to safely access a value.
