From the course: Flask Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Alerting users with message flashing

Alerting users with message flashing

From the course: Flask Essential Training

Start my 1-month free trial

Alerting users with message flashing

- [Announcer] We've written the code. So if someone uses a short name that's already been taken, like in this case with go and they hit the shorten button, it still keeps them on the homepage and clears the data. Now, this is the correct move to take. But the user is left really confused. They think, I just put in a URL, I put in a short name. What's wrong, did it make it? Did something go wrong? They don't really know. So this would be a great opportunity to display some sort of message to the user to say, hey, that's already been taken, you need to pick a new short name for your URL. So this is a great chance to introduce flash inside of flask. It's a great way to display messages or information to your users as you move on to new web pages. So let's move back to our app.py. And this is a new flask skill that we're importing. So let's go to our import line and add flash right up at the top. And then let's move down…

Contents