Bird
0
0

Given this Flask code snippet using a pattern, what will be the output when accessing /hello route?

medium📝 component behavior Q13 of 15
Flask - Ecosystem and Patterns
Given this Flask code snippet using a pattern, what will be the output when accessing /hello route?
from flask import Flask, Blueprint

hello_bp = Blueprint('hello', __name__)

@hello_bp.route('/hello')
def hello():
    return 'Hello, World!'

app = Flask(__name__)
app.register_blueprint(hello_bp)

if __name__ == '__main__':
    app.run()
A404 Not Found error
BHello, World!
C500 Internal Server Error
DBlank page with no content
Step-by-Step Solution
Solution:
  1. Step 1: Understand Blueprint registration

    The Blueprint 'hello_bp' defines route '/hello' and is registered to the app.
  2. Step 2: Check route response

    Accessing '/hello' calls the hello() function returning 'Hello, World!'.
  3. Final Answer:

    Hello, World! -> Option B
  4. Quick Check:

    Registered Blueprint route returns expected string = A [OK]
Quick Trick: Registered Blueprint routes respond correctly [OK]
Common Mistakes:
MISTAKES
  • Forgetting to register the Blueprint
  • Expecting error without route defined
  • Confusing route URL with function name

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes