title: How to separate flask app.route order of events
body: <p>I have a small program that opens up an outlook email when a button is clicked on an html page. The problem is, I don't know the order of my app.route objects and the posted data from my html page.</p>
  <p>My html (openemailJS.html):</p>
    
        <p></p>
    
  <p>my flask app:</p>
  <pre><code>import win32com.client
  from flask import Flask, render_template, jsonify, json, url_for, request, redirect
  import pythoncom, time, os, sys
  
  app = Flask(__name__)
  
  @app.route('/',methods = ['POST', 'GET'])
  def index():
     if request.method == 'POST':
         emailid = request.args.get('nm')
         time.sleep(1)
         pythoncom.CoInitialize()
         outlook = win32com.client.dynamic.Dispatch(&quot;Outlook.Application&quot;).GetNameSpace('MAPI')
         inbox = outlook.GetDefaultFolder(6)
         sentbox = outlook.GetDefaultFolder(5)
         all_sentbox = sentbox.Items
         all_inbox = inbox.Items
         tryopen = outlook.GetItemFromID(emailid)
         tryopen.display()
         return render_template('openemailJS.html')
         print(emailid)
     else:
          time.sleep(1)
          emailid = request.args.get('nm')
          #emailid = request.form.get('nm')
          time.sleep(1)
          pythoncom.CoInitialize()
          outlook = win32com.client.dynamic.Dispatch(&quot;Outlook.Application&quot;).GetNameSpace('MAPI')
          inbox = outlook.GetDefaultFolder(6)
          sentbox = outlook.GetDefaultFolder(5)
          all_sentbox = sentbox.Items
          all_inbox = inbox.Items
          tryopen = outlook.GetItemFromID(emailid)
          tryopen.display()
          print(user)
          return render_template('openemailJS.html')
  </code></pre>
  <p>I think I need to separate the ' return render_template('openemailJS.html') 'into its own app.route('/something here/') but I don't know how to do that.</p>
  <p>Currently, when I run it how it is, the emailid does not get posted before the def index(): runs, causing a 'parameter not found' where it should be. If I comment out everything but the 'return render_template', run the program, and then uncommment it out and click the button, then it gets posted as it should.</p>