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,裝個最新版本就好了...


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM