falsk 请求没有返回值报错

Posted wzbk

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了falsk 请求没有返回值报错相关的知识,希望对你有一定的参考价值。

线上报警 5xx 错误,查看日志发现报这个错,

TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement.

这个方法没有有效的返回结果

页面报这个错误

Internal Server Error

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

服务器遇到内部错误,无法完成您的请求。服务器过载或应用程序出错。

 

代码部分

 1 # flask 请求不可以没有返回值
 2 # The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
 3 import flask
 4 
 5 from flask import Flask, request
 6 
 7 app = Flask(__name__)
 8 
 9 
10 @app.route(/func)
11 # 展示数据
12 def func():
13   return  # 这块有问题
14 # TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement.
15 
16 if __name__ == "__main__":
17     app.run(host=127.0.0.1,port=9090)

修改方法,加个返回值就好了。

以上是关于falsk 请求没有返回值报错的主要内容,如果未能解决你的问题,请参考以下文章

PreparedStatement传进null值报错

org.apache.commons.lang3.tuple.Pair 作为更新参数,XML 中的 Sql 取不到值报错

Mybatis+Oracle搭配insert空值报错问题

MySQL数据库储存bit类型的值报错

dict遍历的时候删除dict中的值报错RuntimeError: dictionary changed size during iteration

sqlserver2005数据库中,修改行中某一列的值报错,怎样才能解决啊。