Bird
0
0

Given a Flask app with this route:

medium📝 component behavior Q4 of 15
Flask - Ecosystem and Patterns
Given a Flask app with this route:
@app.route('/hello')
def hello():
    return 'Hello, Flask!'

What will be the response when accessing /hello URL?
A404 Not Found
BHello, Flask!
CMethod Not Allowed
DInternal Server Error
Step-by-Step Solution
Solution:
  1. Step 1: Understand route decorator

    @app.route('/hello') maps the URL /hello to the hello() function.
  2. Step 2: Check function return value

    The function returns the string 'Hello, Flask!' which is sent as response.
  3. Final Answer:

    The response will be 'Hello, Flask!' -> Option B
  4. Quick Check:

    Route /hello returns 'Hello, Flask!' [OK]
Quick Trick: Route URL matches function return string [OK]
Common Mistakes:
MISTAKES
  • Expecting 404 if route is defined
  • Confusing method errors with route errors
  • Assuming function must return HTML

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes