title: Redirect to a URL which contains a 'variable part' in Flask (Python)
body: <p>I'm trying to redirect to a URL in Flask. The target URL that I'm trying to redirect to has a variable like this <code>/dashboard/&lt;username&gt;</code> which has a view as follows,</p>
  
  <pre><code>@app.route('/dashboard/&lt;username&gt;')
  def dashboard(username):
      return render_template('dashboard.html', username=username)
  </code></pre>
  
  <p>How do I redirect to this URL using the Flask's <code>redirect()</code> &amp; <code>url_for()</code> functions. I have tried this,</p>
  
  <pre><code>return redirect(url_for("index"))
  </code></pre>
  
  <p>which works fine as index is an URL without any variable part (<code>/index</code>) in my application. But, how do I do it for URLs which have variable paths?</p>
  
  <p>Thanks</p>