python - 尝试通过 localhost 连接到烧瓶时出错
问题描述
我可以在 github 上使用烧瓶发送 Post 请求的脚本。
我正在尝试运行脚本以在本地主机上建立连接。但我得到以下回复
The method is not allowed for the requested URL.
@app.route('/', methods = ['POST'])
def index():
if 'file' not in request.files:
return redirect(request.url)
file = request.files['file']
# if user does not select file, browser also
# submit a empty part without filename
if file.filename == '':
flash('No selected file')
return redirect(request.url)
if file and allowed_file(file.filename):
filename = secure_filename(file.filename)
warped = transform_file(file)
return send_from_directory(app.config['UPLOAD_FOLDER'], filename)
if __name__ == '__main__':
app.run(host='127.0.0.1', threaded=True)
解决方案
你试图在你的路线中只有一个根,即“/”。
你可以尝试一个网站,如下所示:
@app.route('/', methods=['GET', 'POST'])
推荐阅读
- optaplanner - VRP 静止查询
- java - 如何等待 WebElement 出现在 DOM 中?
- vue.js - 如何在 vue-authenticate 中为 oauth2 登录设置 client_secret
- .net - 侧面下拉菜单中的复选框
- ios - 使用 Xamarin iOS Today 扩展的 Xamarin Forms
- git - 从存储库中删除后,从所有以前的提交中删除 virtualenv 文件
- excel - 如何使用 VBA 对列中的单元格进行颜色编码并放置在正文电子邮件中
- dynamics-crm - 添加子网格和视图以进行字段更新
- iis - 如何将调试诊断工具作为服务运行
- azure - 事件网格不使用逻辑应用触发