AttributeError: 'Request' object has no attribute 'is_xhr'问题处理

  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/gunicorn/workers/async.py", line 105, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/flask/app.py", line 1994, in __call__
    return self.wsgi_app(environ, start_response)
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/flask/app.py", line 1985, in wsgi_app
    response = self.handle_exception(e)
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/flask/app.py", line 1540, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/www/server/common/decorator.py", line 81, in wrapper
    return jsonify(result_json)
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/flask/json.py", line 251, in jsonify
    if current_app.config['JSONIFY_PRETTYPRINT_REGULAR'] and not request.is_xhr:
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/werkzeug/local.py", line 347, in __getattr__
    return getattr(self._get_current_object(), name)
AttributeError: 'Request' object has no attribute 'is_xhr'

在使用docker部署算法代码的时候报错
发现算法服务的环境和我部署的环境不兼容
查阅了
https://stackoverflow.com/questions/60131900/weird-is-xhr-error-when-deploying-flask-app-to-heroku

我使用了第一种方法:
Stick with your current version of Flask and restrict the Werkzeug version that is fetched explicitly in your application’s setup.py or requirements.txt by specifying werkzeug<1.0
我再pip install的时候指定了werkzeug==0.16.0 即可

或者你可以尝试第二种方法:
Upgrade to a recent version of Flask (>=1.0.0), which is running fine with latest Werkzeug
升级Flask版本

你可能感兴趣的:(docker,python)