gpt4 book ai didi

follow_redirects=True 和 werkzeug>=0.15 时 flask 测试客户端抛出 AttributeError

转载 作者:行者123 更新时间:2023-12-03 16:48:10 24 4
gpt4 key购买 nike

使用 python 3.6,flask 0.12.4

当 werkzeug>=0.15 时失败,在 werkzeug==0.14.1 上运行良好

这里是重现错误所需的最少代码:

from flask import Flask, redirect
app = Flask(__name__)

@app.route("/")
def hello():
return redirect('/')

client = app.test_client()
client.get('/', follow_redirects=True)

这是回溯

Traceback (most recent call last):
File "hello.py", line 9, in <module>
client.get('/', follow_redirects=True)
File "/usr/local/lib/python3.6/site-packages/werkzeug/test.py", line 1028, in get
return self.open(*args, **kw)
File "/usr/local/lib/python3.6/site-packages/flask/testing.py", line 127, in open
follow_redirects=follow_redirects)
File "/usr/local/lib/python3.6/site-packages/werkzeug/test.py", line 1016, in open
response, new_location, environ, buffered=buffered
File "/usr/local/lib/python3.6/site-packages/werkzeug/test.py", line 947, in resolve_redirect
return self.open(builder, as_tuple=True, buffered=buffered)
File "/usr/local/lib/python3.6/site-packages/flask/testing.py", line 122, in open
builder = make_test_environ_builder(self.application, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/flask/testing.py", line 29, in make_test_environ_builder
url = url_parse(path)
File "/usr/local/lib/python3.6/site-packages/werkzeug/urls.py", line 457, in url_parse
i = url.find(s(":"))
AttributeError: 'EnvironBuilder' object has no attribute 'find'

最佳答案

你必须升级 Flask 或降级 Werkzeug。 Werkzeug > 1.0 之前的 Flask 版本不支持 0.14

参见:https://github.com/pallets/flask/issues/3148

关于follow_redirects=True 和 werkzeug>=0.15 时 flask 测试客户端抛出 AttributeError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55579958/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com