Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Flask/Werkzeug, how to return previous page after login

def logged_in(f):
    @wraps(f)
    def decorated_function(*args, **kwargs):
        if session.get('logged_in') is not None:
            return f(*args, **kwargs)
        else:
            flash('Please log in first...', 'error')
            next_url = get_current_url() # However you do this in Flask
            login_url = '%s?next=%s' % (url_for('login'), next_url)
            return redirect(login_url)
    return decorated_function
Comment

PREVIOUS NEXT
Code Example
Python :: pandas drop zeros from series 
Python :: python pandas to visualise the tangent of a curve 
Python :: Django, limit queryset without slicing 
Python :: cours python 
Python :: Python (cpython 2.7.16) sample 
Python :: python compare number with a precision 
Python :: python regex with f-string 
Python :: containsDuplicate Set Solution 
Python :: how to scrape data from github api python 
Python :: ring Sort List Item 
Python :: difflib get close matches 
Python :: delet categories from coco dataset 
Python :: python rational numbers 
Python :: python list insert multiple 
Python :: void setup and void loop 
Python :: matplotlib doesnt show suptitle 
Python :: python 2nd order ode 
Python :: re.split return none in the list 
Python :: y level for iron 
Python :: real python linear regression 
Python :: image processing and resizing with python 
Python :: python generator in while loop 
Python :: pls work 
Python :: seaborn heatmap spearman correlation coefficient 
Python :: replace substrings to float 
Python :: python long numbers as string 
Python :: python break out of function 
Python :: build the .pyx file to c and run on python 
Python :: to_csv zip pandas 
Python :: Overwrite text in python 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =