0
0
Flaskframework~10 mins

Why production setup matters in Flask - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to run a Flask app in development mode.

Flask
if __name__ == '__main__':
    app.run(debug=[1])
Drag options to blanks, or click blank then click option'
A0
BTrue
CNone
DFalse
Attempts:
3 left
💡 Hint
Common Mistakes
Setting debug to False disables helpful error messages.
Using None or 0 does not enable debug mode.
2fill in blank
medium

Complete the code to import the production-ready WSGI server.

Flask
from [1] import WSGIServer
Drag options to blanks, or click blank then click option'
Aflask
Bhttp.server
Cwerkzeug.serving
Dgevent.pywsgi
Attempts:
3 left
💡 Hint
Common Mistakes
Importing from flask or werkzeug.serving is for development only.
http.server is not suitable for production Flask apps.
3fill in blank
hard

Fix the error in the production server start command.

Flask
http_server = WSGIServer(('0.0.0.0', [1]), app)
http_server.serve_forever()
Drag options to blanks, or click blank then click option'
A5000
B'5000'
C'app'
Dapp
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around the port number causes a type error.
Passing the app object as the port causes errors.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension filtering environment variables.

Flask
prod_env = {key: value for key, value in [1].items() if key.[2]('PROD_')}
Drag options to blanks, or click blank then click option'
Aos.environ
Bos.getenv
Cstartswith
Din
Attempts:
3 left
💡 Hint
Common Mistakes
Using os.getenv returns a single value, not a dictionary.
Using 'in' instead of 'startswith' does not filter keys correctly.
5fill in blank
hard

Fill all three blanks to configure Flask app for production.

Flask
app.config['DEBUG'] = [1]
app.config['TESTING'] = [2]
app.config['ENV'] = '[3]'
Drag options to blanks, or click blank then click option'
AFalse
BTrue
Cproduction
Ddevelopment
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving debug or testing enabled in production risks security.
Setting ENV to 'development' causes unwanted debug features.