Bird
0
0

Given this Flask code, what will be the response status code when accessing '/health'?

medium📝 state output Q4 of 15
Flask - Deployment
Given this Flask code, what will be the response status code when accessing '/health'?
from flask import Flask
app = Flask(__name__)

@app.route('/health')
def health():
    return 'Healthy', 200
A200 OK
B500 Internal Server Error
C404 Not Found
D302 Redirect
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the route and return statement

    The route '/health' is defined and returns a tuple with body 'Healthy' and status 200.
  2. Step 2: Understand Flask response behavior

    Flask uses the second tuple element as the HTTP status code, so response status is 200.
  3. Final Answer:

    200 OK -> Option A
  4. Quick Check:

    Return tuple with 200 sets status code 200 [OK]
Quick Trick: Return ('text', 200) sets HTTP status 200 [OK]
Common Mistakes:
MISTAKES
  • Assuming default 404 if not careful
  • Confusing return string with status code
  • Expecting redirect without code

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes