title: Flask / Python: @after_this_request is not accessed
body: <p>I trying to delete a file I've created after it was displayed on the webservice.
  However with the current placement of the function, it says 'remove_file(response) is not accessed' and when I run the webservice I get an error when outputting the file, as it apparently already has been deleted.</p>
  <p>I don't know what to do anymore, I've tried placing the afer_this_request function right after the upload_file declaration, after the return render template, all of it never works. I'm going crazy, so any help would make my year!</p>
  <pre><code>    @app.route('/', methods=['POST', 'GET'])
      def upload_file():
          if request.method == 'POST':
              myuuid = uuid.uuid4()
              # check if the post request has the file part
              if 'file' not in request.files:
                  return render_template('error.html')
              file = request.files['file']
              # If the user does not select a file, the browser submits an
              # empty file without a filename.
              if file.filename == '':
                  return render_template('error.html')
      
              if file and allowed_file(file.filename):
                  sfilename = secure_filename(file.filename)
                  if not os.path.exists(app.config['UPLOAD_FOLDER']):
                      os.mkdir(app.config['UPLOAD_FOLDER'])
                  output_path = os.path.join(app.config['UPLOAD_FOLDER'], sfilename)
                  file.save(output_path)
      
         
                  if 'Alpha Miner' in request.form:
                      Alpha(pro_file, myuuid)
                      img_url = url_for('static', filename=str(myuuid) + '.gv.svg')
      
                      @after_this_request
                      def remove_file(response):
                          os.remove(img_url)
                          return response
                    
                      titel = &quot;Petri Net for Alpha Miner: &quot; + sfilename    
                      return render_template('upload.html', img_url=img_url, titel = title)
  </code></pre>