ImportError: cannot import name 'SharedDataMiddleware' from 'werkzeug'

Ask Questions Forum: ask Machine Learning Questions to our readersCategory: Machine LearningImportError: cannot import name 'SharedDataMiddleware' from 'werkzeug'
Adesoji Alu asked 9 months ago

@app.route(‘/uploads/’)
def uploaded_file(filename):
return send_from_directory(app.config[‘UPLOAD_FOLDER’],
filename)
from werkzeug import SharedDataMiddleware
app.add_url_rule(‘/uploads/’, ‘uploaded_file’,
build_only=True)
app.wsgi_app = SharedDataMiddleware(app.wsgi_app, {
‘/uploads’: app.config[‘UPLOAD_FOLDER’]
})

if __name__ == “__main__”:
app.debug=False
app.run(host=’127.0.0.5′, port=3000)

Error below
File “C:\Users\Sortol\Downloads\Compressed\AIFlowers2-master\app.py”, line 94, in
from werkzeug import SharedDataMiddleware
ImportError: cannot import name ‘SharedDataMiddleware’ from ‘werkzeug’ (C:\Users\Sortol\anaconda3\lib\site-packages\werkzeug\__init__.py)

Please what did i do wrong. i have the module werkzeug installed.

2 Answers
Best Answer
Adesoji answered 9 months ago

solved by importing rightly. from werkzeug.middleware.shared_data import SharedDataMiddleware

Adesoji answered 9 months ago

from werkzeug.middleware.shared_data import SharedDataMiddleware

Your Answer

8 + 20 =