ValueError通用WSGI请求错误的值太多,无法解包(预期2)

时间:2020-10-27 11:35:52

标签: python python-3.x flask

我正在以下URL上运行一个flask应用程序,正在对其进行OPTIONS调用

/test//

正确的域名是/test/user-name/。但是以某种方式在选项调用中缺少用户名。

以上情况导致我的应用程序中断。

回溯如下:

Traceback (most recent call last):
  File "/home/company/Documents/project/lib/python3.8/site-packages/werkzeug/serving.py", line 323, in run_wsgi
    execute(self.server.app)
  File "/home/company/Documents/project/lib/python3.8/site-packages/werkzeug/serving.py", line 312, in execute
    application_iter = app(environ, start_response)
  File "/home/company/Documents/project/lib/python3.8/site-packages/flask/app.py", line 2464, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/company/Documents/project/lib/python3.8/site-packages/flask_request_id_header/middleware/__init__.py", line 51, in __call__
    return self.app(environ, new_start_response)
  File "/home/company/Documents/project/lib/python3.8/site-packages/newrelic/api/wsgi_application.py", line 664, in _nr_wsgi_application_wrapper_
    result = _WSGIApplicationMiddleware(wrapped,
  File "/home/company/Documents/project/lib/python3.8/site-packages/newrelic/api/wsgi_application.py", line 192, in __init__
    self.iterable = self.application(self.request_environ,
  File "/home/company/Documents/project/lib/python3.8/site-packages/flask/app.py", line 2450, in wsgi_app
    response = self.handle_exception(e)
  File "/home/company/Documents/project/lib/python3.8/site-packages/flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/company/Documents/project/lib/python3.8/site-packages/flask_restful/__init__.py", line 269, in error_router
    return original_handler(e)
  File "/home/company/Documents/project/lib/python3.8/site-packages/newrelic/hooks/framework_flask.py", line 108, in _nr_wrapper_Flask_handle_exception_
    return wrapped(*args, **kwargs)
  File "/home/company/Documents/project/lib/python3.8/site-packages/flask/app.py", line 1867, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/company/Documents/project/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/home/company/Documents/project/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/company/Documents/project/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/company/Documents/project/lib/python3.8/site-packages/flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/company/Documents/project/lib/python3.8/site-packages/flask_restful/__init__.py", line 269, in error_router
    return original_handler(e)
  File "/home/company/Documents/project/lib/python3.8/site-packages/newrelic/hooks/framework_flask.py", line 108, in _nr_wrapper_Flask_handle_exception_
    return wrapped(*args, **kwargs)
  File "/home/company/Documents/project/lib/python3.8/site-packages/flask/app.py", line 1816, in handle_user_exception
    return self.handle_http_exception(e)
  File "/home/company/Documents/project/lib/python3.8/site-packages/newrelic/hooks/framework_flask.py", line 90, in _nr_wrapper_Flask_handle_http_exception_
    return wrapped(*args, **kwargs)
  File "/home/company/Documents/project/lib/python3.8/site-packages/flask/app.py", line 1744, in handle_http_exception
    return handler(e)
  File "/home/company/Documents/project/lib/python3.8/site-packages/newrelic/hooks/framework_flask.py", line 126, in _nr_wrapper_error_handler_
    return wrapped(*args, **kwargs)
  File "/home/company/Documents/project/service/app/code_service.py", line 81, in page_not_found
    return Response(
  File "/home/company/Documents/project/lib/python3.8/site-packages/werkzeug/wrappers/base_response.py", line 187, in __init__
    self.headers = Headers(headers)
  File "/home/company/Documents/project/lib/python3.8/site-packages/werkzeug/datastructures.py", line 958, in __init__
    self.extend(defaults)
  File "/home/company/Documents/project/lib/python3.8/site-packages/werkzeug/datastructures.py", line 1101, in extend
    for key, value in iter_multi_items(args[0]):
ValueError: too many values to unpack (expected 2) | line-113 |

请帮助我解决此问题。这是app.py文件的链接。

https://github.com/shubhamkumar0/medilink/blob/master/app.py

预先感谢!

1 个答案:

答案 0 :(得分:0)

响应头作为一组传递,我更改为map,问题得到解决。谢谢您的时间。