"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "docs/patterns/fileuploads.rst" between
flask-1.1.1.tar.gz and flask-1.1.2.tar.gz

About: Flask is a lightweight Python WSGI web application framework.

fileuploads.rst  (flask-1.1.1):fileuploads.rst  (flask-1.1.2)
skipping to change at line 124 skipping to change at line 124
@app.route('/uploads/<filename>') @app.route('/uploads/<filename>')
def uploaded_file(filename): def uploaded_file(filename):
return send_from_directory(app.config['UPLOAD_FOLDER'], return send_from_directory(app.config['UPLOAD_FOLDER'],
filename) filename)
Alternatively you can register `uploaded_file` as `build_only` rule and Alternatively you can register `uploaded_file` as `build_only` rule and
use the :class:`~werkzeug.wsgi.SharedDataMiddleware`. This also works with use the :class:`~werkzeug.wsgi.SharedDataMiddleware`. This also works with
older versions of Flask:: older versions of Flask::
from werkzeug import SharedDataMiddleware from werkzeug.middleware.shared_data import SharedDataMiddleware
app.add_url_rule('/uploads/<filename>', 'uploaded_file', app.add_url_rule('/uploads/<filename>', 'uploaded_file',
build_only=True) build_only=True)
app.wsgi_app = SharedDataMiddleware(app.wsgi_app, { app.wsgi_app = SharedDataMiddleware(app.wsgi_app, {
'/uploads': app.config['UPLOAD_FOLDER'] '/uploads': app.config['UPLOAD_FOLDER']
}) })
If you now run the application everything should work as expected. If you now run the application everything should work as expected.
Improving Uploads Improving Uploads
----------------- -----------------
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)