Redirect to a URL which contains a 'variable part' in Flask (Python) -
i'm trying redirect url in flask. target url i'm trying redirect has variable /dashboard/<username>
has view follows,
@app.route('/dashboard/<username>') def dashboard(username): return render_template('dashboard.html', username=username)
how redirect url using flask's redirect()
& url_for()
functions. have tried this,
return redirect(url_for("index"))
which works fine index url without variable part (/index
) in application. but, how do urls have variable paths?
thanks
you want create url url_for
giving name of url, keyword arg
, , value url parameter in following manner:
return redirect(url_for('dashboard', username='foo'))
Comments
Post a Comment