Bird
0
0

Which of the following is the correct way to start a basic Flask app?

easy📝 Syntax Q12 of 15
Flask - Ecosystem and Patterns
Which of the following is the correct way to start a basic Flask app?
Afrom flask import Flask app = Flask() @app.route('/') def home(): return 'Hello World!'
Bimport django app = django.App() @app.route('/') def home(): return 'Hello World!'
Cfrom flask import Flask app = Flask(__name__) @app.route('/') def home(): return 'Hello World!'
Dfrom flask import Flask app = Flask(__file__) @app.route('/') def home(): return 'Hello World!'
Step-by-Step Solution
Solution:
  1. Step 1: Check Flask app initialization

    Flask apps require passing __name__ to Flask() for correct setup.
  2. Step 2: Verify route and function syntax

    from flask import Flask app = Flask(__name__) @app.route('/') def home(): return 'Hello World!' correctly imports Flask, initializes app with __name__, and defines a route with a function returning a string.
  3. Final Answer:

    Correct Flask app start with __name__ -> Option C
  4. Quick Check:

    Flask(__name__) is correct app init [OK]
Quick Trick: Flask app needs Flask(__name__) to start [OK]
Common Mistakes:
MISTAKES
  • Using Flask() without __name__
  • Confusing Django import with Flask
  • Passing wrong argument like __file__

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes