flask中return render_template报The view function did not return a valid response.

今天做项目的时候遇到了一个很坑人的问题,此处记录一下…
本人是用flask作为开发框架。

  • 原本代码如下:
class IndexHtml():
    def index():
        return render_template("/index.html")
      
def index_html(index):
    index.add_url_rule("/", view_func=IndexHtml.index, methods=['GET'])

今天在使用render_template返回前端模板的时候,突然报错,每次访问,都报
The view function did not return a valid response. The return type must be a string, dict, tuple, Response instance, or WSGI callable, but it was a NotRequestPowerError.
个人感觉代码没有任何问题。
刚开始在网上找类似错误的时候都在说是没有return,只写了render_template,但是不符合我的问题,最近抱着试试的态度更新了一下flask版本结果莫名其妙的解决了,特此记录。
所以只需要直接再次pip install flask就好

猜你喜欢

转载自blog.csdn.net/qq_46170664/article/details/124520543
今日推荐