我目前正在尝试上传一张图片,稍后再处理它。但我得到一个405错误,我不知道如何修复它
@app.route('/upload')
def upload():
return render_template('upload.html')
@app.route('/uploader', methods = ['GET', 'POST'])
def upload_f():
if request.method == 'POST':
f = request.files['file']
f.save(f.filename)
return 'file uploaded successfully'
html表单
<html>
<body>
<form action = "http://localhost:5000/uploader" method = "POST"
enctype = "multipart/form-data">
<input type = "file" name = "file" />
<input type = "submit"/>
</form>
</body>
</html>
来自Miguel Grinberg的Handling File Uploads With Flask教程:
相关问题 更多 >
编程相关推荐