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'
のために許可されていませんこれは私のhtmlです:フラスコファイルのアップロード、方法が要求されたURL
<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">
これは私のAPIコードです:
@api.route('/upload', methods=['POST','GET'])
def upload():
if request.method == 'POST':
file = request.files['file']
upload_path = os.path.join(APP_STATIC_TXT, secure_filename(file.filename))
file.save(upload_path)
return redirect(url_for('/'))
この実行結果:
INFO: werkzeug:127.0.0.1 - - [14/Dec/2017 16:26:42] "POST /api/v1.0/upload HTTP/1.1" 400 - INFO:werkzeug:127.0.0.1 - - [14/Dec/2017 16:26:42] "POST/HTTP/1.1" 405 - INFO:werkzeug: * Detected change in '/home/python/Desktop/VCG/vcg/api_1_0/test01.py', reloading
これは、Web htmlです:
Method Not Allowed
方法は、要求されたURLに許可されていません。
ここにコードを入れて、正しくフォーマットしてください。 –