title: Flask return redirect() call not redirecting user
body: <p>I have a flask site that I am running locally using flask's built-in development server (local machine).  </p>
  
  <p>Before I serve a page, I am running a custom security evaluation function to ensure the user is entitled to access the page.  If the user is not entitled to access the page, I am attempting to redirect the user back to the home page.  Everything in this workflow is happening as intended, except the redirect.  </p>
  
  <p>The user is being served the page as if they are perfectly entitled, even though the "redirect" call is still being executed.  It's most likely I'm using the redirect function incorrectly -- please enlighten me.</p>
  
  <p>Here's the flask site setup:</p>
  
  <pre><code>from flask import Flask, render_template, request, url_for, redirect, Markup, session, abort
  
  def security(page_name):
      # Direct not logged in users to the login form
      if not session.get('logged_in'):
          return render_template('login.html')
      else:
          try:
              # Update user's permissions
              permissions_list = login_helpers.get_user_permissions_by_id(user_id)
              session['permissions'] = permissions_list
  
              if requested_page_abbreviation not in session['permissions']:
                  # User does not have access -- bounce user back to home
  
                  # I see this appear in the console
                  print('Not authorized')
  
                  # This must get executed, but the user does not get directed back home -- instead the resulting page loads as if the user has permissions
                  return redirect('/home')
  
                  # This does not execute
                  # If I replace this line above the "return redirect('/home')" call, the expected "Unauthorized" page results and the 401 HTTP code is returned
                  abort(401)
  
  
          except KeyError:
  
              # User has not yet had permissions set -- bounce user back to home to login
              return redirect(url_for('home'))
  
  @app.route('/', methods=['GET','POST'])
  def home():
      return render_template('home.html')
  
  @app.route('/test_page', methods=['POST'])
  def test_page():
  
      security_check('TEST')
  
      return render_template('test_page.html')
  </code></pre>