from flask import Flask
from flask.ext.uploads import UploadSet, configure_uploads, IMAGES
app = Flask(__name__)
app.config['UPLOADED_PHOTOS_DEST'] = '/home/kevin'
photos = UploadSet('photos', IMAGES)
configure_uploads(app, (photos,))
以上是我的代码,但它给了我以下错误:
Traceback (most recent call last):
File "./main.py", line 10, in <module>
configure_uploads(app, (photos,))
File "/usr/lib/python3.5/site-packages/flaskext/uploads.py", line 197, in configure_uploads
should_serve = any(s.base_url is None for s in set_config.itervalues())
AttributeError: 'dict' object has no attribute 'itervalues'
我使用 Flask 0.10.1 和 Flask-Uploads 0.1.3 ,我的部分代码不正确?
答案 0 :(得分:1)
dict.itervalues()
仅在python2.x中,我认为即席上传不支持3.x而且setup.py
也没有说他们支持3.x
答案 1 :(得分:1)
正如您所注意到的,由于调用dict.itervalues()
,Flask-Uploads 0.1.3不支持Python 3。
我最近接手了Flask-Uploads项目的维护者,并接受了在this commit修复该问题的公关。
包含此修补程序的0.2.0版本尚未推送到Pypi,但在此之前,您可以直接从GitHub安装Python 3兼容版本:
pip install git+https://git@github.com/jeffwidman/flask-uploads.git
如果您遇到任何问题,问题跟踪器就在此处:https://github.com/jeffwidman/flask-uploads/issues