8

I have a flask app, where i have implemented a snippet, to check if a user is logged in, in order to acces certain webpages on my application.

My method looks like this:

#check if session is avaliable to access hidden pages for non users
def is_logged_in(f):
    @wraps(f)
    def wrap(*args, **kwargs):
        if 'logged_in' in session:
            return f(*args, **kwargs)
        else:
            flash('Please Login ', 'danger')
            return redirect(url_for('login'))
    return wrap

Here I check if the session has a logged_in attribute attached the the session.

However, I get an error saying global name @wraps is not defined, but I have no idea as to why?

khelwood
  • 55,782
  • 14
  • 81
  • 108
kristof
  • 121
  • 1
  • 4

1 Answers1

22

you are probably missing wraps from functools

from functools import wraps
L3viathan
  • 26,748
  • 2
  • 58
  • 81
Krypotos
  • 346
  • 2
  • 4