I want to redefine a function from a .py file which is created when i installed flask package

Viewed 17

There is a file in the following location /Python37/Lib/site-packages/flask_login/utils.py

def expand_login_view(login_view):
    """
    Returns the url for the login view, expanding the view name to a url if
    needed.

    :param login_view: The name of the login view or a URL for the login view.
    :type login_view: str
    """
    if login_view.startswith(("https://", "http://", "/")):
        return login_view

    return url_for(login_view)

this is a function defined in the utils.py file.. i want this to be like the following

def expand_login_view(login_view):
    """
    Returns the url for the login view, expanding the view name to a url if
    needed.

    :param login_view: The name of the login view or a URL for the login view.
    :type login_view: str
    """
    if login_view.startswith(("https://", "http://", "/")):
        return login_view

    try:
        return url_for(login_view)
    except:
        return url_for(login_view, ROLE='User')

if i change in the original file it works well but it will be altered for the whole time and it looks like hard coding.. so plz help me
My @app_route look like this

@app.route('/login/<ROLE>/', methods=['GET', 'POST'])
def login_page(ROLE):
    ...
    ...
    return render_template('sample.html', keys=ROLE)
0 Answers
Related