title: Flask: wait until file will be stored by send_file command
body: <p>By POST request I am going to let client store generated file to his local HHD by executing send_file() command. Here is the code:</p>
  <pre><code>def send_file_to():
      try:
          file_name = store_user_list()
          send_file(file_name, as_attachment=True, conditional=True)
          script_message = &quot;File has been provided&quot;
      except Exception as e:
          script_message = &quot;File sending Error: &quot; + str(e)
      return render_template('result.html', result_message=script_message)
  </code></pre>
  <p>unfortunately, it doesn't store file. Only if I change the script to:</p>
  <pre><code>       return send_file(file_name......
  </code></pre>
  <p>But I would like to get back on result.html page in any result. The command above leave me on the same page where I pressed the button &quot;Download File&quot;.</p>
  <p>Should I check any other event in @app to catch when download is finished?</p>
  <p>Can you please help me understand the workflow that let me have required behaviour.</p>