Complete the code to set the Content-Type header for JSON responses.
headers = {"Content-Type": "[1]"}Setting the Content-Type to application/json tells clients to expect JSON data, which improves usability by providing a consistent format.
Complete the code to parse a JSON response body.
data = response.[1]()text() returns raw string, not parsed JSON.html() or content() does not parse JSON.Using json() parses the response body as JSON, ensuring consistent data format handling.
Fix the error in the code to send a JSON payload in a POST request.
response = requests.post(url, json=[1])The json parameter expects a Python dictionary, not a string. Passing a dict ensures the library serializes it properly.
Fill both blanks to create a dictionary comprehension that filters JSON keys starting with 'user'.
filtered = {key: value for key, value in data.items() if key [1] 'user'[2]Using startswith('user') filters keys that begin with 'user', improving consistent data handling.
Fill all three blanks to create a JSON response with a consistent format including status and data.
response = [1]({{"status": [2], "data": [3])
make_response without JSON conversion.Using jsonify creates a JSON response. The status is a string, and data is the payload dictionary, ensuring consistent API output.