Challenge - 5 Problems
Health Check Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate1:30remaining
What is the output of this Flask health check endpoint?
Consider this Flask app code snippet for a health check endpoint. What will the endpoint return when accessed?
Flask
from flask import Flask, jsonify app = Flask(__name__) @app.route('/health') def health_check(): return jsonify(status='ok', uptime=12345), 200 # Assume the server is running and /health is accessed
Attempts:
2 left
💡 Hint
Flask's jsonify returns JSON with correct headers.
✗ Incorrect
The endpoint returns a JSON response with keys 'status' and 'uptime' and HTTP status 200.
📝 Syntax
intermediate1:30remaining
Which option causes a syntax error in this Flask health check route?
Identify which Flask route definition will cause a syntax error.
Flask
from flask import Flask, jsonify app = Flask(__name__) # Four route definitions below
Attempts:
2 left
💡 Hint
Check for missing colons in function definitions.
✗ Incorrect
Option A is missing a colon after the function definition, causing a syntax error.
❓ state_output
advanced1:30remaining
What is the HTTP status code returned by this health check endpoint?
Given this Flask health check endpoint, what HTTP status code will the client receive?
Flask
from flask import Flask, jsonify app = Flask(__name__) @app.route('/health') def health_check(): response = jsonify(status='ok') response.status_code = 503 return response
Attempts:
2 left
💡 Hint
The status_code attribute sets the HTTP status code.
✗ Incorrect
The code sets response.status_code to 503, so the client receives HTTP 503 Service Unavailable.
🔧 Debug
advanced2:00remaining
Why does this Flask health check endpoint raise a TypeError?
Examine the code and identify why it raises a TypeError when accessed.
Flask
from flask import Flask, jsonify app = Flask(__name__) @app.route('/health') def health_check(): data = {'status': 'ok'} return jsonify(data, 200)
Attempts:
2 left
💡 Hint
Check the signature of jsonify function.
✗ Incorrect
jsonify expects keyword arguments or a single dict, not multiple positional arguments. Passing (data, 200) causes TypeError.
🧠 Conceptual
expert1:30remaining
Which option best describes the purpose of a health check endpoint in Flask?
Select the most accurate description of why a health check endpoint is used in a Flask application.
Attempts:
2 left
💡 Hint
Think about monitoring and uptime checks.
✗ Incorrect
Health check endpoints are lightweight URLs that return app status, used by monitoring tools to verify the app is running.