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'))
This is web run result:
把最后一行
改成