背景

有一个 Flask 项目,然后有一个路由返回的是 dict

Flask - 访问返回字典的接口报错:The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a dict.

Flask - 访问返回字典的接口报错:The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a dict.

 

通过浏览器访问,结果报错

Flask - 访问返回字典的接口报错:The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a dict.

 

关键报错信息

TypeError: 'dict' object is not callable
The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a dict.

意思是不能返回 dict

 

解决方案

结果是版本太老了,用的 Flask 1.0.2....我服了,之前跑别人的项目装了个老版 Flask,装个最新版本就好了...

相关文章:

  • 2022-12-23
  • 2021-07-22
  • 2021-06-09
  • 2021-07-16
  • 2021-05-05
  • 2022-12-23
猜你喜欢
  • 2021-09-29
  • 2022-12-23
  • 2022-12-23
  • 2021-05-03
  • 2021-06-10
  • 2021-10-18
  • 2022-02-25
相关资源
相似解决方案