I am using flask's application factory and I am trying to exempt a route. If I put csrf.exempt(team_routes.team_bp)
it works, but I only need to exempt the team_bp.stat
route. I have tried csrf.exempt(team_routes.team_bp.team_stats)
csrf = CSRFProtect()
def create_app()
....
csrf.init_app(app)
with app.app_context():
app.register_blueprint(team_route.team_bp)
my team_route.py
file
team_bp = Blueprint()
@team_route.route('/stat/')
@current_app.csrf.exempt
def team_stats():
When adding @current_app.csrf.exempt
in the route I get the following error Flask object has no attribute csrf
. If I add the csrf_token()
to the form and submit it works. But I want to have the stat
route exempt