Created
October 3, 2015 05:11
-
-
Save pawl/ee7c76bb066b7d1cbe5d to your computer and use it in GitHub Desktop.
Pillow==3.0.0 flask temporary file issue
This file contains hidden or 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
| from flask import Flask, url_for, redirect, request | |
| from PIL import Image | |
| app = Flask(__name__) | |
| def allowed_file(filename): | |
| return '.' in filename and \ | |
| filename.rsplit('.', 1)[1] in ('gif', 'jpg', 'jpeg', 'png', 'tiff') | |
| @app.route('/', methods=['GET', 'POST']) | |
| def upload_file(): | |
| if request.method == 'POST': | |
| file = request.files['file'] | |
| if file and allowed_file(file.filename): | |
| image = Image.open(file) | |
| return ''' | |
| <!doctype html> | |
| <title>Upload new File</title> | |
| <h1>Upload new File</h1> | |
| <form action="" method=post enctype=multipart/form-data> | |
| <p><input type=file name=file> | |
| <input type=submit value=Upload> | |
| </form> | |
| ''' | |
| if __name__ == "__main__": | |
| app.run(debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment