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‘)

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

原文地址:https://www.cnblogs.com/wzbk/p/11011115.html

时间: 2024-08-28 10:23:20

falsk 请求没有返回值报错的相关文章

wcf返回值报错解析

问题来源 最近在项目中使用wcf,因为是一个新手,对新的东西总是比较敬畏,不过一切都是进行得很顺利,运行的时候,突然报了错,编译器提示的错误大概是:“InvalidOperationException:无法加载操作“UploadResourceNotInDb”,它具有类型为 System.ServiceModel.Channels.Message 的参数或返回类型,或具有一个带有 MessageContractAttribute 及其他不同类型参数的类型.”! 服务契约(Service Cont

linux编程中接收主函数返回值以及错误码提示

程序A创建子进程,并调用进程B,根据不调用的不同情况,最后显示结果不同. #include <stdio.h> #include <unistd.h> #include <sys/wait.h> #include <sys/types.h> #include <errno.h> int main() { pid_t pid, rpid; int stat; if ((pid = fork()) < 0) { perror("for

VC++ 通过ADO连接数据库查询时返回空值报错的解决方案

当数据库的字段值允许为空时, 而且此时内容也为空时,则执行查询会出错,例如 CString str = pRecordset->GetFields()->GetItem((long)0)->GetValue(); 或者 str= pRecordset->GetCollect("posInfo"); 会弹出如下窗口提示出错! 更加奇怪的是  catch(...)也抓不到异常 今天碰着个问题算是头弄大了  最后终于弄好了 报错的原因:   在GetCollct返回了

VUE.JS 使用axios数据请求时数据绑定时 报错 TypeError: Cannot set property &#39;xxxx&#39; of undefined 的解决办法

正常情况下在data里面都有做了定义 在函数里面进行赋值 这时候你运行时会发现,数据可以请求到,但是会报错 TypeError: Cannot set property 'listgroup' of undefined 主要原因是: 在 then的内部不能使用Vue的实例化的this, 因为在内部 this 没有被绑定.可以看下 Stackoverflow 的解释: 解决办法: 1.用ES6箭头函数,箭头方法可以和父方法共享变量 2.在请求axios外面定义一下 var that=this 问题

VUE - 使用axios数据请求时数据绑定时 报错 TypeError: Cannot set property &#39;xxxx&#39; of undefined 的解决办法

created() { var that=this axios.get('http://jsonplaceholder.typicode.com/todos') .then(function (res) { // handle success // console.log(res); that.todos = res.data }) .catch(function (error) { // handle error console.log(error); }) .finally(function

redis取值报错

> get "all_couriers_on_the_job" (error) ERR Operation against a key holding the wrong kind of value #类型不对,所以报错,先查看值的类型: > type "all_couriers_on_the_job" hash > HGETALL "all_couriers_on_the_job" 1) "47" 2) &

c#获取url请求的返回值

/// <summary> /// 获取url的返回值 /// </summary> /// <param name="url">eg:http://m.weather.com.cn/atad/101010100.html </param> public string GetInfo(string url) { string strBuff = ""; Uri httpURL = new Uri(url); ///Ht

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

当我们储存bit类型的值时,不能直接写入数字 上图中的画圈部分就是bit类型,若是直接填入"1"或"0"等等就会报错,如下: 这时候,我们要看bit(M)的M值是多少,若M=4,则写成b'0001';若M=6,则写成b'000001'即可

PreparedStatement传进null值报错

最近在测试jdbc数据导入大量数据的性能,发现PreparedStatement传进null值会报错. 解决方法: setObject(int parameterIndex, Object x, int targetSqlType) 如:preparedStatement.setObject(10,org.springframework.util.StringUtils.isEmpty(row[9]) ? null : Integer.parseInt(row[9]),java.sql.Type