添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
逼格高的牛腩  ·  Class ...·  3 周前    · 
帅气的火腿肠  ·  ALDI奥乐齐官方网站·  4 月前    · 
踏实的风衣  ·  TB 10106-2010 ...·  4 月前    · 
刚毅的刺猬  ·  [CMake] find_package ...·  6 月前    · 
打酱油的荒野  ·  #2435 (moov atom not ...·  9 月前    · 
飞奔的篮球  ·  Pronouncing L, R, S, ...·  11 月前    · 

I am using Dash on top of Flask and after upgrading to Python 3.10 I get the following TypeError when loading the main app in my browser:

Traceback (most recent call last):
  File "[PATH_TO_VIRTUALENV]/lib/python3.10/site-packages/flask/app.py", line 2213, in __call__
    return self.wsgi_app(environ, start_response)
  File "[PATH_TO_VIRTUALENV]/lib/python3.10/site-packages/flask/app.py", line 2193, in wsgi_app
    response = self.handle_exception(e)
  File "[PATH_TO_VIRTUALENV]/lib/python3.10/site-packages/flask/app.py", line 2190, in wsgi_app
    response = self.full_dispatch_request()
  File "[PATH_TO_VIRTUALENV]/lib/python3.10/site-packages/flask/app.py", line 1487, in full_dispatch_request
    return self.finalize_request(rv)
  File "[PATH_TO_VIRTUALENV]/lib/python3.10/site-packages/flask/app.py", line 1506, in finalize_request
    response = self.make_response(rv)
  File "[PATH_TO_VIRTUALENV]/lib/python3.10/site-packages/flask/app.py", line 1837, in make_response
    raise TypeError(
TypeError: The view function did not return a valid response. The return type must be a string, dict, list, tuple with headers or status, Response instance, or WSGI callable, but it was a Dash.

I realise this error is typically raised when a Flask route returns data of the wrong type, but as you can see in the traceback the error is not raised from one of my routes or callbacks. All steps in the traceback point to the flask module. A simplified version of my app looks roughly like this. Any pointers?

app.py

from flask import Flask
from subfolder.main import register_module
app = Flask(__name__)
app = register_module(app)
if __name__ == "__main__":
    flask.run(debug=True, port=8000)

subfolder/main.py

def register_module(flask: Flask) -> Flask:
    dash = Dash(
        __name__,
        server=flask,
    # Dash logic lives here, a few callbacks and routes
    return flask
              

Thanks for the quick reply!

I have tried several versions of Dash, and am currently on 2.11.1.

For Flask, flask --version returns

Python 3.10.6
Flask 2.2.5
Werkzeug 2.2.3