Bird
0
0

What will happen if you run flask hello given this code?

medium📝 Predict Output Q5 of 15
Flask - Ecosystem and Patterns
What will happen if you run flask hello given this code?
from flask import Flask
app = Flask(__name__)

@app.cli.command()
def hello():
    print('Hi there!')
AIt prints nothing
BIt prints 'Hi there!'
CIt raises a runtime error
DIt shows a list of available commands
Step-by-Step Solution
Solution:
  1. Step 1: Identify the command name

    The function hello decorated with @app.cli.command() creates a CLI command named 'hello'.
  2. Step 2: Predict command behavior

    Running flask hello calls the function, printing 'Hi there!'.
  3. Final Answer:

    It prints 'Hi there!' -> Option B
  4. Quick Check:

    CLI command runs function and prints output [OK]
Quick Trick: Command name matches function name by default [OK]
Common Mistakes:
MISTAKES
  • Expecting error without reason
  • Thinking command name differs from function
  • Assuming no output is printed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes