0
0
Flaskframework~20 mins

Debug mode error pages 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 and an error occurs?
Consider a Flask app running with debug mode enabled. What will the user see if the app raises an unhandled exception during a request?
Flask
from flask import Flask
app = Flask(__name__)
app.debug = True

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

if __name__ == '__main__':
    app.run()
AA detailed interactive error page with the traceback and the ability to execute code in the browser.
BThe app crashes and stops running immediately.
CThe app silently ignores the error and returns a blank page.
DA generic 500 Internal Server Error page with no details shown.
Attempts:
2 left
💡 Hint
Debug mode shows detailed error information to help developers fix bugs.
📝 Syntax
intermediate
2:00remaining
Which code snippet correctly enables debug mode in Flask?
You want to enable debug mode in your Flask app to see detailed error pages during development. Which of the following code snippets correctly enables debug mode?
A
app = Flask(__name__)
app.debug = True
app.run()
B
app = Flask(__name__)
app.run(debug=False)
C
app = Flask(__name__)
app.debug = False
app.run()
D
app = Flask(__name__)
app.run(debug=True)
Attempts:
2 left
💡 Hint
The debug parameter in app.run controls debug mode.
🔧 Debug
advanced
2:00remaining
What error occurs if you try to enable debug mode in production with Flask's built-in server?
You accidentally run your Flask app with debug=True on a public server. What error or warning will Flask show or raise?
Flask
from flask import Flask
app = Flask(__name__)

@app.route('/')
def index():
    return 'Hello'

if __name__ == '__main__':
    app.run(debug=True, host='0.0.0.0')
AWarning: Do not use debug mode in production! The server will refuse to start.
BRuntimeError: Debugger PIN required for remote access
CNo error; the app runs normally with debug mode enabled on all interfaces.
DValueError: Host '0.0.0.0' is not allowed with debug mode.
Attempts:
2 left
💡 Hint
Flask protects the interactive debugger from remote access with a PIN.
state_output
advanced
2:00remaining
What is the output when Flask debug mode is disabled and an error occurs?
Given this Flask app with debug mode off, what will the user see if an unhandled exception is raised?
Flask
from flask import Flask
app = Flask(__name__)
app.debug = False

@app.route('/')
def index():
    raise Exception('Error!')

if __name__ == '__main__':
    app.run()
AThe error is ignored and the page loads normally.
BA detailed interactive error page with traceback and debugger.
CA simple 500 Internal Server Error page with no traceback details.
DThe app crashes and stops running.
Attempts:
2 left
💡 Hint
Without debug mode, Flask hides error details from users.
🧠 Conceptual
expert
2:00remaining
Why is it unsafe to run Flask with debug mode enabled on a public server?
Select the best explanation for why Flask's debug mode should never be enabled on a public-facing server.
ABecause the interactive debugger allows remote code execution, exposing the server to security risks.
BBecause debug mode slows down the server significantly, causing performance issues.
CBecause debug mode disables HTTPS, making data insecure.
DBecause debug mode automatically deletes all user data on errors.
Attempts:
2 left
💡 Hint
Think about what the interactive debugger can do if accessed by attackers.