title: In Flask, how can I generate a dynamic URL upon button click?
body: <p>For example, now if I have two buttons in a form element, when you click on either one of them, you'll be directed to the corresponding profile.</p>
  
  <pre><code>&lt;form action="{{ url_for('getProfile') }}" method="post"&gt;
      &lt;button type="submit" name="submit" value="profile1"&gt; View Profile&lt;/button&gt;
      &lt;button type="submit" name="submit" value="profile2"&gt; View Profile&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>In my apprunner.py, I have</p>
  
  <pre><code> @app.route('/profile', methods=['POST'])
   def getProfile():
         if request.form['submit'] = 'profile1':
              return render_template("profile1.html")
         else if request.form['submit'] = 'profile2':
              return render_template("profile2.html")
  </code></pre>
  
  <p>However, my problem is when I click on either button, the url will always be something like "127.0.0.1:5000/profile". But, I want it to look like "<a href="http://127.0.0.1:5000/profile1" rel="nofollow noreferrer">http://127.0.0.1:5000/profile1</a>" or "<a href="http://127.0.0.1:5000/profile2" rel="nofollow noreferrer">http://127.0.0.1:5000/profile2</a>".</p>
  
  <p>I have looked for solution on how to generate dynamic URL online, but none of them works for button click.</p>
  
  <p>Thanks in advance!</p>