0
0
Flaskframework~20 mins

Development server with debug mode in Flask - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Flask Debug Mode Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What happens when Flask debug mode is enabled?
Consider a Flask app started with debug mode enabled. What is the main behavior you will observe during development?
Flask
from flask import Flask
app = Flask(__name__)

@app.route('/')
def home():
    return 'Hello, Flask!'

if __name__ == '__main__':
    app.run(debug=True)
AThe server disables the debugger and requires manual restarts on code changes.
BThe server automatically reloads on code changes and shows detailed error messages in the browser.
CThe server runs in production mode with caching enabled.
DThe server runs slower but disables all error messages for security.
Attempts:
2 left
💡 Hint
Think about what debug mode helps developers do easily.
📝 Syntax
intermediate
1:30remaining
Which code correctly enables debug mode in Flask?
Select the code snippet that correctly starts a Flask app with debug mode enabled.
Aapp.run(debug='True')
Bapp.run(debug=1)
Capp.run(debug='yes')
Dapp.run(debug=True)
Attempts:
2 left
💡 Hint
Debug expects a boolean value, not a string.
🔧 Debug
advanced
2:30remaining
What error occurs if you run Flask with debug=True but forget to set __name__ == '__main__'?
Given this code snippet, what error or behavior will occur? from flask import Flask app = Flask(__name__) @app.route('/') def home(): return 'Hi' app.run(debug=True)
Flask
from flask import Flask
app = Flask(__name__)

@app.route('/')
def home():
    return 'Hi'

app.run(debug=True)
ARuntimeError: The server is running but debug mode causes multiple reloads and crashes.
BThe server starts but immediately crashes with RuntimeError about working outside the main thread.
CThe server starts but runs the app twice due to the reloader causing duplicate output.
DThe server starts normally but debug mode is ignored and no auto-reload happens.
Attempts:
2 left
💡 Hint
Think about how Flask's reloader works when not protected by the main guard.
state_output
advanced
2:00remaining
What is the output when Flask debug mode triggers an error in a route?
If a route function raises an exception while Flask is running with debug=True, what will the user see in the browser?
Flask
from flask import Flask
app = Flask(__name__)

@app.route('/')
def home():
    raise ValueError('Oops!')

if __name__ == '__main__':
    app.run(debug=True)
AA detailed interactive debugger page showing the error and stack trace.
BA plain 500 Internal Server Error page with no details.
CThe browser shows a blank page with no response.
DThe server crashes and stops running immediately.
Attempts:
2 left
💡 Hint
Debug mode helps developers see what went wrong directly in the browser.
🧠 Conceptual
expert
3:00remaining
Why should Flask debug mode never be enabled in production?
Select the best reason why running Flask with debug=True is unsafe in a production environment.
ADebug mode enables an interactive debugger that can execute arbitrary code, exposing the server to attacks.
BDebug mode disables all security features, allowing anyone to access the server files.
CDebug mode slows down the server drastically, causing denial of service.
DDebug mode automatically deletes logs and user data after each request.
Attempts:
2 left
💡 Hint
Think about what the interactive debugger allows a user to do.