title: Why is tornado self.post finishing with a call to self.get?
body: <p>I've inherited a Python tornado project. I'm not super familiar with Tornado. </p>
  
  <p>The problem is; when a call to classname.post is complete, the python attempts to redirect to a webpage. On that webpage, clicking OK then redirects to another page. </p>
  
  <p>However, when you click OK on the browser (to trigger the redirect in the HTML/JS), Tornado instead calls the classname.get() method and does not go to the redirect. </p>
  
  <p>** Application **</p>
  
  <pre><code>class Application(tornado.web.Application):
      def __init__(self):
          handlers = [
              (r"/internal/meta_(\w\w\w\w\w\w\w$)", InternalMetaHandler),
              (r"/", WelcomeHandler),
              (r"/input_data", InputHandler),
              (r"/external/meta_(\w\w\w\w\w\w\w$)", ExternalMetaHandler),
              (r"/static/(.*)", tornado.web.StaticFileHandler,
               {"path": os.path.join(os.path.dirname(os.path.abspath("overview.html")), "static/")}),
          ]
  
          settings = dict(
              debug=True,  # TODO SWITCH OFF!!! autoreload server when changes are detected
          )
  
          tornado.web.Application.__init__(self, handlers, **settings)
  </code></pre>
  
  <p>** InputHandler **</p>
  
  <pre><code>class InputHandler(tornado.web.RequestHandler, MetaD):
  
      def get(self):
          log.debug("IN InputHandler.get()...")
  
      def post(self):
          log.debug('post input received')
          # Parse the data passed in from the form dict            
          data_from_web = self.request.arguments.get("slug")[0]  # load data                 
              # This works
          &lt;open file for read&gt;
              # This works
          &lt;open file for write&gt;
              # This works
          &lt;Try to update GIT&gt;
              # This fails so we update the messages
              feedback_title  = "There were errors..."
              feedback_string = "FILE UPLOAD(s): (Nothing to upload)&lt;BR&gt;DATA CHANGES: OK&lt;BR&gt;GIT UPDATE: failed! (No error message) Files will be pushed on next run when git is available."
  
          self.render("static/InputHandlerComplete.html", received_title = feedback_title, received_message=feedback_string)
          # ALSO TRIED
          # self.redirect("static/InputHandlerComplete.html", received_title = feedback_title, received_message=feedback_string)
  </code></pre>
  
  <p>** InputHandlerComplete.html **</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8"/&gt;
      &lt;title&gt;Metadata-Feedback&lt;/title&gt;
      &lt;link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css"&gt;
      &lt;script src="/static/bootstrap/js/bootstrap.min.js"&gt;&lt;/script&gt;
      &lt;style media="screen" type="text/css"&gt;
          html,
          body {
              height: 100%;
          }
  
          .container {
              width: 500px;
              height: 50%;
              display: flex;
              justify-content: center;
              align-items: center;
          }
  
      &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div class="container"&gt;
      &lt;div&gt;
          &lt;h1&gt;{% autoescape None %}{{received_title}}&lt;/h1&gt;
          {% autoescape None %}{{received_message}}
          &lt;form&gt;
              &lt;button id="myButton" &gt;OK&lt;/button&gt;
  
              &lt;script type="text/javascript"&gt;
                  document.getElementById("myButton").onclick = function () {
                      location.href = "http://172.xxx.xxx.xxx:xxxx/external/meta_7699587";
                  };
              &lt;/script&gt;
          &lt;/form&gt;        
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><BR>
  ** Sending form to POST results in the correct InputHandlerComplete.html page**
  <a href="https://i.stack.imgur.com/fYM8w.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fYM8w.png" alt="enter image description here"></a>
  <BR>
  <BR>
  ** Clicking OK within InputHandlerComplete.html does NOT go to the link in the HTML code, but instead goes to to InputHandler.get() (see the blank page image below, and the log) **
  <a href="https://i.stack.imgur.com/pBt7J.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pBt7J.png" alt="enter image description here"></a></p>
  
  <p><strong>log</strong></p>
  
  <pre><code>("Submit" button to the form was pressed here. Data is sent as a "POST")
  
  [D 180403 12:44:51 loghandler:795] post input received
  [D 180403 12:44:51 loghandler:795] (new_output_data) Opening '/home/metadata/metadata-prototype/implementation/server/../../metadata/projects/mirko_test_aff1f69/mirko_test_aff1f69.json' for read  ...OK
  [D 180403 12:44:51 loghandler:795] (new_output_data) Opening '/home/metadata/metadata-prototype/implementation/server/../../metadata/projects/mirko_test_aff1f69/mirko_test_aff1f69.json' for write ...OK
  [D 180403 12:44:51 loghandler:795] Updating GIT...
  [D 180403 12:44:51 loghandler:795] GIT return code was '1'
  [D 180403 12:44:51 loghandler:795] (No error message)
  [D 180403 12:44:51 loghandler:795] GIT UPDATE: failed! (No error message)
       Files will be pushed on next run when git is available.
  [D 180403 12:44:51 loghandler:795] (new_output_data) Opening '/home/metadata/metadata-prototype/implementation/server/../../metadata/projects/mirko_test_aff1f69/mirko_test_aff1f69.json' for write ...OK
  [I 180403 12:44:51 web:2064] 200 POST /input_data (172.16.168.1) 30.21ms
  
  (OK BUTTON ON THE "There were errors..." REDIRECT PAGE WAS CLICKED HERE)
  
  [D 180403 12:45:25 loghandler:795] IN InputHandler.get()...
  [I 180403 12:45:25 web:2064] 200 GET /input_data (172.16.168.1) 1.64ms
  </code></pre>