Recall & Review
beginner
What is the purpose of flash message categories in Flask?
Flash message categories help organize messages by type, such as 'error', 'success', or 'info'. This allows different styles or behaviors for each message type in the user interface.
Click to reveal answer
beginner
How do you specify a category when flashing a message in Flask?
You pass the category as the second argument to the
flash() function, like flash('Message text', 'category').Click to reveal answer
beginner
Name three common flash message categories used in Flask applications.
Common categories include success (for positive feedback), error (for problems or failures), and info (for general information).
Click to reveal answer
intermediate
How can you access the category of a flashed message in a Flask template?
Use
get_flashed_messages(with_categories=True) in the template to get a list of tuples with (category, message). Then you can style messages based on their category.Click to reveal answer
beginner
Why is it helpful to use categories with flash messages instead of just plain messages?
Categories let you show messages differently, like red for errors or green for success. This improves user experience by making messages clear and easy to understand.Click to reveal answer
In Flask, how do you add a category to a flash message?
✗ Incorrect
You add the category as the second argument in the flash() function, like flash('Hello', 'info').
Which function helps retrieve flash messages with their categories in Flask templates?
✗ Incorrect
Use get_flashed_messages(with_categories=True) to get messages along with their categories.
What category would you use for a message confirming a successful action?
✗ Incorrect
The 'success' category is used for positive feedback messages.
Why are flash message categories useful in a web app?
✗ Incorrect
Categories let you style messages differently, improving clarity and user experience.
If you call flash('Error occurred', 'error'), what category is assigned?
✗ Incorrect
The category assigned is 'error' as given in the second argument.
Explain how flash message categories work in Flask and why they are helpful.
Think about how you tell users different types of messages clearly.
You got /4 concepts.
Describe how to retrieve and use flash message categories inside a Flask template.
Remember how you get both message and its type to show them nicely.
You got /4 concepts.