在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/Python/ Flask upload , The method is not allowed

Flask upload , The method is not allowed for the requested URL,

I am trying to upload file. the abnormal is 'The method is not allowed for the requested URL' after run .  However my code is request methods is 'POST'

This is my a part of html:

<form action="" enctype='multipart/form-data' method="POST">
<span class="btn btn-info" id="import">
<input type="file" name="file">
</span>input type="submit" value="upload" id="submit">

This is my api code and run result:

@api.route('/upload', methods=['POST','GET'])
def upload():
if request.method == 'POST':
    print '-'*100
    print request.files
    f = request.files['file']
    upload_path = os.path.join(APP_STATIC_TXT, secure_filename(f.filename))
    file.save(upload_path)
    return redirect(url_for('/upload'))

clipboard.png
This is web run result:

clipboard.png

回答
編輯回答
蔚藍(lán)色

把最后一行

return redirect(url_for('/upload'))

改成

return render_template('你的html')
2017年4月5日 21:43