Flask socketServer 错误请求 - python 3.8

问题描述 投票:0回答:0

我正在为 API 服务设置一个 python flask。但是根据要求得到一个错误。我正在使用 python 版本 3.8

这是我的

manager.py

import unittest
import time
from app import app, manager

@manager.command
def run():
    """Run the app."""
    app.run(host='0.0.0.0')

if __name__ == '__main__':
    manager.run()

我运行命令

python manager.py run
它显示:

$ python manage.py run

* Serving Flask app "app" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: on

但是当我通过路由点击请求时它显示错误:

----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 50776)
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 50778)
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 650, in process_request_thread
    self.finish_request(request, client_address)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 720, in __init__
    self.handle()
  File "/Users/selim.bongo/Sites/python/digital-agency-ms/venv/lib/python3.8/site-packages/werkzeug/serving.py", line 327, in handle
    rv = BaseHTTPRequestHandler.handle(self)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/server.py", line 425, in handle
    self.handle_one_request()
  File "/Users/selim.bongo/Sites/python/digital-agency-ms/venv/lib/python3.8/site-packages/werkzeug/serving.py", line 361, in handle_one_request
    elif self.parse_request():
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/server.py", line 351, in parse_request
    conntype = self.headers.get('Connection', "")
AttributeError: module 'http.client' has no attribute 'get'
----------------------------------------

建议解决此问题的方法。

python flask
© www.soinside.com 2019 - 2024. All rights reserved.