title: When using redirect() in Flask, HTML is written to Console
body: <p>So I've been working in Flask and ran into an irritating problem. I'm creating a website and using the redirect function the website doesn't switch pages. Each place I'm attempting to go to can render_template() when not called via redirect. Here's my code (yes, the hashed_password isn't hashed and I should probable redirect to next, but these are are problems for another day):</p>
  
  <pre><code>@app.route('/logIn',methods=['Get', 'Post'])
  def logIn():
      _name = request.form['inputName']
      _password = request.form['inputPassword']
      # _hashed_password = bcrypt.hashpw(_password, bcrypt.gensalt( 12 ))
      _hashed_password = _password
  
      conn = mysql.connect()
      cursor = conn.cursor()
      cursor.execute("SELECT * FROM tbl_user WHERE user_name = '" + _name + "'")
  
      user = cursor.fetchone()
      print(user[0])
  
      if len(user[2]) is not 0 and user[3] == _password:
  
          active_user = User(user[0])
          login_user(active_user)
          return (redirect(url_for('home')))
      else:
  
          return json.dumps({'message': 'Username or Password not correct'})
  
  
  @app.route('/Home')
  @login_required
  def home():
      return render_template("home.html")
  </code></pre>
  
  <p>This all works with a html and js background. The HTML doesn't have any code, only contains the button to be clicked (though if it'll help I can post the html). The JS looks like this for the login button:</p>
  
  <pre><code>$(function() {
      $('#btnLogIn').click(function() {
  
          $.ajax({
              url: '/logIn',
              data: $('form').serialize(),
              type: 'POST',
              success: function(response) {
                  console.log(response);
              },
              error: function(error) {
                  console.log(error);
              }
      });
  });
  </code></pre>
  
  <p>});</p>
  
  <p>Finally, the output spits back the html for the Home page, the one I want to be rendering in the browser (this is the output):</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
    &lt;head&gt;
      &lt;title&gt;Python Flask Bucket List App&lt;/title&gt;
        &lt;script src="static/js/jquery-3.3.1.min.js"&gt;&lt;/script&gt;
        &lt;script src="static/js/logout.js"&gt;&lt;/script&gt;
    &lt;/head&gt;
  
    &lt;body&gt;
     &lt;form class="form-signout"&gt;
         &lt;button id="btnLogOut" class="btn btn-lg btn-primary btn-block" type="button"&gt;Log Out&lt;/button&gt;
     &lt;/form&gt;
    &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>I've been looking everywhere. Also, adding /Home after the local host domain calls the same GET as the one called after clicking the button and successfully loads the page. If anyone knows how to do this with loading the "next" url, that would be even better.</p>