flask报错The view function did not return a valid response

本来报错内容是 The view function did not return a valid response. The function either returned None or ended without a return statement.

本来没有最后的return语句,经查阅后最后添加了 return "没有进入if",结果显示

img

怎样让语句进入if ?最后应该显示的是一个返回的表单内容

代码如下

img

result.html里的内容

img

如果我所猜不错的话,可能是因为你的methods里面的方面大小写问题,之前我遇到过,改成methods=['GET','POST']就好了~~虽然有点扯,但是我当时就是这么解决的。

前端加上form表单

<form method="post" action="">