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 项目,然后有一个路由返回的是 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,装个最新版本就好了...

posted @ 2021-08-21 23:31  小菠萝测试笔记  阅读(3580)  评论(0编辑  收藏  举报