Recall & Review
beginner
What does the
redirect() function do in Flask?The
redirect() function sends the user to a different URL. It tells the browser to load a new page, like when you click a link.Click to reveal answer
beginner
How do you use the
abort() function in Flask?You call
abort() with an HTTP status code (like 404) to stop the request and show an error page. It’s like saying "Stop! This page is not found."Click to reveal answer
intermediate
What HTTP status code does
redirect() usually use by default?By default,
redirect() uses status code 302, which means "Found" or "Temporary Redirect." It tells the browser to go to the new URL temporarily.Click to reveal answer
beginner
What happens if you call
abort(404) in a Flask route?Flask stops running the route and sends a 404 Not Found error page to the user. This means the page does not exist.
Click to reveal answer
intermediate
Can you customize the error page shown by
abort() in Flask?Yes! You can create custom error handlers for codes like 404 or 500 to show friendly messages or pages instead of the default error page.
Click to reveal answer
What does
redirect('/home') do in a Flask app?✗ Incorrect
redirect('/home') tells the browser to go to the '/home' page.
Which function stops a Flask route and shows an error page?
✗ Incorrect
abort() stops the route and sends an error response.
What HTTP status code is commonly used by
abort(404)?✗ Incorrect
abort(404) sends a 404 Not Found error.
Which status code does
redirect() use by default?✗ Incorrect
Default redirect status code is 302 (Temporary Redirect).
How can you show a custom error page for
abort(404) in Flask?✗ Incorrect
Custom error handlers let you show friendly pages for errors.
Explain how and why you would use the
redirect() function in a Flask app.Think about when you want to send someone to a different page after an action.
You got /4 concepts.
Describe the purpose of the
abort() function and how it affects the user experience in Flask.Consider what happens when a page is not found or access is denied.
You got /4 concepts.