Q:

Flask won't continue to execute after redirect

I'm new to Flask.  I want to create a simple project that I can upload the file to web, call the exe program to process the file and output the log of the process.  I tried to modified a little the template for file upload from  http://flask.pocoo.org/docs/0.12/patterns/fileuploads/ to implement with the features I want.  
I managed to browse and save the file to my directory, but I couldn't run the processing_call method.  However, I tried refresh the page and found that it can run the exe program.  This means that processing_call works.  But what I want is to call the exe without the need to refresh the page. 
This is my code:
@app.route('/', methods=['GET', 'POST'])
def upload_file():
if request.method == 'POST':
    # check if the post request has the file part
    if 'file' not in request.files:
        flash('No file part')
        return redirect(request.url)
    file = request.files['file']
    # if user does not select file, browser also
    # submit a empty part without filename
    if file.filename == '':
        flash('No selected file')
        return redirect(request.url)
    if file and allowed_file(file.filename):
        filename = secure_filename(file.filename)
        file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
        return redirect(url_for('uploaded_file',
                                filename=filename))
        processing_file()
return render_template('uploadfile.html',subprocess_output=processing_file())

A:

In Python language, code after return statement will never work (it is same in all languages as I know).  So if you need to do something, execute it before return.  If you don't want to block user while executing function, you will need task queue (https://www.fullstackpython.com/task-queues.html) to make call it asynchronously.