title: Jinja2 html buttons: Catch POST on different pages
body: <p>I've got a GAE-app that uses Jinja2 templates to serve its html pages.</p>
  
  <p>Now in my main python file I've got one class, mainhandler, with a GET and a POST method. This all works for the welcome screen where there is a button to do something. When the button is clicked, the POST method is invoked which calls a second page. </p>
  
  <p>I can't find anything about how to catch the button events on the second page, result.html. And make it progress methods in the main python file.</p>
  
  <p>So: "How can I work with errorMail and toCalendar buttons on result.html?</p>
  
  <p>This is my main file:</p>
  
  <pre><code># -*- coding: utf8 -*- 
  
  import webapp2
  from apiclient.discovery import build
  from oauth2client.appengine import OAuth2Decorator
  
  from format import formatFile
  
  import jinja2
  import os
  
  jinja_environment = jinja2.Environment(
      loader=jinja2.FileSystemLoader(os.path.dirname(__file__)))
  
  decorator = OAuth2Decorator(secret)
  
  class MainHandler(webapp2.RequestHandler):
      @decorator.oauth_required
      def get(self):
          template = jinja_environment.get_template('index.html')
          self.response.out.write(template.render())
  
      #processes the file and shows the results
      def post(self):
          # Get the authorized Http object created by the decorator.
          http = decorator.http()
  
          service = build('calendar', 'v3', http=http,
             developerKey='secret')
  
          # Make a list of calendars
          calendar_list = service.calendarList().list().execute()
  
          totalList = formatFile(self.request.get('file'))
  
          template_values = {"totalList": totalList, "calendar_list": calendar_list}
  
          template = jinja_environment.get_template('result.html')
          self.response.out.write(template.render(template_values))
  
  
  app = webapp2.WSGIApplication([('/', MainHandler)],
                                debug=True)
  </code></pre>
  
  <p>This is page index.html:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
  &lt;html&gt;
    &lt;head&gt;&lt;title&gt;&lt;/title&gt;&lt;/head&gt;
    &lt;body&gt;
      &lt;form method="post"&gt;
      &lt;div&gt;&lt;label&gt;Select file:&lt;/label&lt;/div&gt;
      &lt;input type="file" name="file"&gt;
      &lt;br&gt;
      &lt;input type="submit" name="upload" value="Upload"&gt;
      &lt;/form&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This is page result.html:</p>
  
  <p></p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
  
      &lt;/head&gt; 
      &lt;body&gt;
          &lt;h3&gt;De volgende data staat klaar voor je agenda:&lt;/h3&gt;
          &lt;table border="1" cellpadding="3"&gt;
              &lt;tr&gt;
                  &lt;th&gt;Dag&lt;/th&gt;
                  &lt;th&gt;Datum&lt;/th&gt;
                  &lt;th&gt;Tijd&lt;/th&gt;
                  &lt;th&gt;Omschrijving&lt;/th&gt;
              &lt;/tr&gt;
                   {% for line in totalList %}
                  &lt;tr&gt;
                      {% for item in line %}
                      &lt;td&gt;{{ item }}&lt;/td&gt;
                      {% endfor %}
              &lt;/tr&gt;        
              {% endfor %}
          &lt;/table&gt;
  
          &lt;br&gt;
          &lt;b&gt;Selecteer de agende waar de diensten in geplaatst worden:&lt;/b&gt;
          &lt;br&gt;
          &lt;select&gt;
              {% for calendar_list_entry in calendar_list['items'] %}
              &lt;option value=&gt;{{ calendar_list_entry['summary'] }}&lt;/option&gt;
              {% endfor %}
          &lt;/select&gt;
          &lt;br&gt;
  
          &lt;form method="post"&gt;
              &lt;input type="submit" name="toCalendar" value="In kalender plaatsen"&gt;
          &lt;/form&gt;
          &lt;br&gt;
          &lt;b&gt;Uitvoer incorrect? Klik dan op onderstaande knop om foutmeldings-email te sturen.&lt;/b&gt;
          &lt;form method="post"&gt;
              &lt;input type="submit" name="errorMail" value="Uitvoer incorrect!"&gt;
          &lt;/form&gt;
  
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>