title: Make drag and drop uploader in flask
body: <p>I'm  trying to make upload site that takes request and stores the files in 'static' folder in flask. I always get bad request when I try sending "POST" request on in.The only reason that I need it is to test my drag and drop javascript uploader. Can someone point me in the right direction?</p>
  
  <pre><code>import os
  from flask import Flask, request, redirect, url_for
  from werkzeug import secure_filename
  
  UPLOAD_FOLDER = 'static'
  ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'])
  
  app = Flask(__name__)
  app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
  
  
  def allowed_file(filename):
      return '.' in filename and \
             filename.rsplit('.', 1)[1] in ALLOWED_EXTENSIONS
  
  @app.route('/', methods=['GET', 'POST'])
  def upload_file():
      if request.method == 'POST':
          file = request.files['xhr2upload'] # [0]
          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))
      return '''
      &lt;!doctype html&gt;
      &lt;title&gt;Upload new File&lt;/title&gt;
      &lt;h1&gt;Upload new File&lt;/h1&gt;
      &lt;form action="" method=post enctype=multipart/form-data&gt;
        &lt;p&gt;&lt;input type=file name=file&gt;
           &lt;input type=submit value=Upload&gt;
      &lt;/form&gt;
      '''
  
  if __name__ == '__main__':
      app.run()
  </code></pre>