Skip to content

Instantly share code, notes, and snippets.

@perone
Created April 10, 2012 18:44
Show Gist options
  • Save perone/2353596 to your computer and use it in GitHub Desktop.
Save perone/2353596 to your computer and use it in GitHub Desktop.
Simple flask upload
import os
from flask import Flask, request, url_for
from werkzeug import secure_filename
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def upload_file():
if request.method == 'POST':
file = request.files['file']
file.save(os.path.join('uploaded_file', secure_filename(file.filename)))
return 'Done !'
return '''
<!doctype html>
<form action="" method=post enctype=multipart/form-data>
<input type=file name=file>
<input type=submit value=Upload>
</form>
'''
if __name__ == '__main__':
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment