lennard lennard - 2 months ago 9
Python Question

Accessing Flask parameter outside called function

Without passing

user_name
to
other_function
as a param, how would I be able to access
user_name
?

@app.route('/profile/<user_name>/')
def profile(user_name):
other_function()
# do more stuff

def other_function():
print request.args

Answer

You can reach the view arguments via request.view_args, which is a dictionary:

def other_function():
    print request.view_args['user_name']