title: Flask Flash message not showing after redirecting to the same page
body: <p>I have a simple web page where the user selects a file from their computer and then presses an "Upload" button, after which a python script will be initiated with that file as an input.</p>
  
  <p>However, I'm trying to get it so that if the user is uploading a file that will throw an error, a Flash message will show on the same page (without any redirection). In my current attempt, the flash message isn't showing when I choose to upload a purposefully erroneous file.</p>
  
  <p>Also, as another question, is it possible to (within app.py) check for certain backend <em>python</em> error messages that will arise once I initiate the script (the ones that will show in the terminal)?</p>
  
  <p>Anyways, here is the relevant code:</p>
  
  <p><strong>app.py:</strong></p>
  
  <pre><code>@app.route("/", methods=['GET', 'POST'])
  def upload():
      if request.method == 'POST':
          if 'file' not in request.files:
              flash("No file chosen", 'danger')
              return redirect(request.url)
          file = request.files['file']
          if file.filename == '':
              flash('No selected file', 'danger')
              return redirect(request.url)
          elif not allowed_file(file.filename):
              flash('Incorrect file extenstion. Must be .TXT!', 'danger')
              return redirect(request.url)
          elif file:
              filename = secure_filename(file.filename)
              file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
              #
              # Process the file (omitted here)
              #
  
              proc = subprocess.Popen('python author_script.py {} -p {} -s {} -m {}'.format(file.filename, period, space, affiliation), shell=True, stdout=subprocess.PIPE)
              time.sleep(0.5)
              return redirect(url_for('results'))
          else:
              # THIS PART IS NOT WORKING!
              return redirect(request.path)
              flash('There is an affiliation missing from your Place list.', 'danger')
      return render_template('index.html', template_file=app.config['TEMPLATE_FILE'])
  </code></pre>
  
  <p><strong>html template (layout.html):</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta charset="utf-8"&gt;
          &lt;title&gt;Author Script&lt;/title&gt;
          &lt;link rel="stylesheet" type="text/css" href="static/main.css" /&gt;
      &lt;/head&gt;
      &lt;body&gt;
          {% include 'includes/_navbar.html' %}
          {% block body %}{% endblock %}
          {% with messages = get_flashed_messages(with_categories=true) %}
              {% if messages %}
                  {% for category, message in messages %}
                      &lt;div class="alert alert-{{ category }}"&gt;
                          {{ message }}
                      &lt;/div&gt; 
                  {% endfor %}
              {% endif %}
          {% endwith %}
          &lt;/div&gt;
  
          &lt;!-- Scripts --&gt;
              &lt;script src="js/jquery.min.js"&gt;&lt;/script&gt;
              &lt;script src="js/skel.min.js"&gt;&lt;/script&gt;
              &lt;script src="js/util.js"&gt;&lt;/script&gt;
              &lt;script src="js/main.js"&gt;&lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>