Created
April 10, 2012 18:44
-
-
Save perone/2353596 to your computer and use it in GitHub Desktop.
Simple flask upload
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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