Skip to content

6.1.0

Choose a tag to compare

@CheeseCake87 CheeseCake87 released this 21 Feb 16:19
· 7 commits to main since this release

Ability to pass a Flask Response as a failure option in a checkpoint.

from flask import render_template
from flask_imp import Flask

from flask_imp.security import checkpoint, SessionCheckpoint

from flask import make_response

def failed_response():
    return make_response({
        "message": "You must be logged in to access this page."
    })

CHECKPOINT = SessionCheckpoint("logged_in", True).action(
    fail_response=failed_response
)

def include(app: Flask):
    @app.route("/", methods=["GET"])
    @checkpoint(CHECKPOINT)
    def index():
        return render_template(bp.tmpl("index.html"))