O'Reilly logo

Instant Flask Web Development by Ron DuPlain

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sending error responses (Simple)

In this section, we will send an error page to the user with style.

Getting ready

We are working from the app.py file inside the sched directory of our project, and in the templates directory inside sched. Create a directory named error inside the templates directory.

How to do it...

  1. When the user hits a Not Found page, we want to display a page that will direct them back to the appointment list. You can tell Flask how to render responses for error cases, typically for HTTP error codes. We will provide a custom 404 Not Found page as shown in the following screenshot:
    How to do it...
  2. Flask provides app.errorhandler to tell Flask how to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required