June 2019
Beginner to intermediate
770 pages
19h 24m
English
A Flask application must have the blueprints registered. In some cases, there will be multiple instances of a blueprint, each at a different point in the URI path. In our case, we only have a single instance of the blueprint at the root of the URI path.
In the preceding examples, the bad request data was signaled by raising a BadRequest exception. A Flask error handler can be defined to transform an exception object to a standardized RESTful response document in JSON format.
The example Flask application is shown here:
class BadRequest(Exception): passdef make_app() -> Flask: app = Flask(__name__) @app.errorhandler(BadRequest) def error_message(ex) -> Tuple[Dict[str, Any], HTTPStatus]: current_app.logger.error(f" ...
Read now
Unlock full access