Aly*_*Aly 2 python upload image flask
嗨,我有以下 html
<form action="classify_upload" method="post" id="upload-form">
<input type="file" name="imagefile" id="imagefile"/>
<input type="submit" />
</form>
Run Code Online (Sandbox Code Playgroud)
在我的flaskwebapp 中,我有以下规则:
@webapp.route('/upload', methods=['POST'])
def upload():
try:
imagefile = flask.request.files('imagefile', '')
...
except Exception as err:
...
Run Code Online (Sandbox Code Playgroud)
但这给了我以下例外
'ImmutableMultiDict' object is not callable
Run Code Online (Sandbox Code Playgroud)
我不知道这意味着什么,也不知道为什么会发生。有任何想法吗?
改变这一行:
imagefile = flask.request.files('imagefile', '')
Run Code Online (Sandbox Code Playgroud)
到:
imagefile = flask.request.files.get('imagefile', '')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17457 次 |
| 最近记录: |