0PricingLogin
Flask Academy · Lesson

abort and HTTP Error Codes

Stop a request with a proper status.

Stopping a Request Early

Sometimes a view should stop right away, like when an item is missing. Flask gives you abort to bail out with the correct HTTP error.

Import abort

You bring it in straight from Flask. Then a single call ends the request and skips the rest of your view code.

from flask import abort

All lessons in this course

  1. abort and HTTP Error Codes
  2. Register errorhandler Functions
  3. Raise Custom Exception Classes
  4. Uniform JSON Error Envelopes
← Back to Flask Academy