Complete the code to import the Flask class from the flask module.
from flask import [1] app = Flask(__name__)
The Flask class is imported from the flask module to create the app instance.
Complete the code to define a custom 404 error handler using the decorator.
@app.errorhandler([1]) def not_found(error): return 'Page not found', 404
The 404 error code means the page was not found, so the handler uses 404.
Fix the error in the code to return a custom 500 error page with a template.
@app.errorhandler(500) def server_error(error): return [1]('500.html'), 500
render_template is used to return an HTML template as a response.
Fill both blanks to create a 404 error handler that returns a template and status code.
@app.errorhandler([1]) def page_not_found(error): return [2]('404.html'), 404
The handler uses 404 for the error code and render_template to return the HTML page.
Fill all three blanks to create a Flask app with custom 404 and 500 error handlers returning templates.
from flask import Flask, [1] app = Flask(__name__) @app.errorhandler(404) def not_found(error): return [2]('404.html'), 404 @app.errorhandler(500) def server_error(error): return [3]('500.html'), 500
render_template is imported and used in both error handlers to return HTML pages.