添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

现象(描述)

现象:TypeError: 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 list.
描述:在使用Flask写接口的过程中,请求URL http://192.168.5.20:5000/diagnosis?symptom_word=%E5%91%BC%E5%90%B8%E8%A1%B0%E7%AB%AD%20%E5%91%BC%E5%90%B8%E5%9B%B0%E9%9A%BE%20%E8%85%B9%E5%BC%8F%E5%8F%8D%E5%B8%B8%E5%91%BC%E5%90%B8 ,返回值报如上的错。

flask下面的jsonify函数作用是,返回一个JSON类型的Response(一般用于把数据返回给前端,否则前端不能获取有效的数据,没有使用Python自带的json模块返回JSON数据,jsonify具有诸多自带JSON模块没有的特性,以更加适应前端,符合前端协议要求格式)

将需要返回的数据,使用jsonify返回。即将

return disease_list
from flask import jsonify
return jsonify(disease_list)
                    在使用Flask写接口的过程中,报错TypeError: 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 list.
				
今天用execjs调用JS时,发现报错execjs._exceptions.ProgramError: ReferenceError: document is not defined 错误类型:文档对象未定义,解决方法,定义对象即可,习惯性定义变量嘛 var document ;?   emmmmmmmmmmmmmmm….不行的,继续报错  execjs._exceptions.ProgramError: TypeError: Cannot read property 'createElement' of undefined 若是报错:execjs._exceptions.Prog
记一次flask项目开发中遇到的无脑问题。 TypeError: The view function did not return a valid response. The function either returned None #错误的原因是,代码中缺少return @app.route('/history_ocr/', methods=['GET', 'POST']) def history_ocr(): if request.method == 'GET': result
网上查了很多资料,都没解决这个问题,方法已经有return了,但是还是报错TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement. 后来才发现,我另外一个蓝图里面有个同名的路径,该同名路径无返回值。所以,在出现这种情况下,也要检查一下是否其他蓝图里有同名的路径
url与视图的函数映射 访问book/list的url的时候发现是不可以访问的,因为我们返回额不是字典、元组等等,现在返回的是一个列表。 TypeError: 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 list. 翻译:该视图没有返回一个可以响应的类型,如字
TypeError: The view function for ‘uploadImg’ did not return a valid response. The function either returned None or ended without a return statement. 解决方法: ①给函数写返回值(return一个值) ②看其他同名函数是否也return ③看看是不是代码少写了method 具体原博客添加链接描述 可能是前端没写也可能是后端没写 ④函数只有在if的时候有返回值,但
线上报警 5xx 错误,查看日志发现报这个错, TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement. 这个方法没有有效的返回结果 页面报这个错误 Internal Server E...
Flask视图函数默认是不能返回list对象和None的,如果返回数据不对,就会抛出异常 TypeError: 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 JsonResponse. 以下将Flask改造为视图函数返回支持list、dict、None
这个错误怎么解决:192.168.34.71 - - [14/Jan/2023 22:41:01] "GET /get_nb2_ip/ HTTP/1.1" 500 - Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 2548, in __call__ return self.wsgi_app(environ, start_response) File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 2528, in wsgi_app response = self.handle_exception(e) File "/usr/local/lib/python3.8/dist-packages/flask_cors/extension.py", line 165, in wrapped_function return cors_after_request(app.make_response(f(*args, **kwargs))) File "/usr/local/lib/python3.8/dist-packages/flask_cors/extension.py", line 165, in wrapped_function return cors_after_request(app.make_response(f(*args, **kwargs))) File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 2525, in wsgi_app response = self.full_dispatch_request() File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1823, in full_dispatch_request return self.finalize_request(rv) File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1842, in finalize_request response = self.make_response(rv) File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 2170, in make_response raise TypeError( TypeError: The view function did not return a valid response. The return type must be a string, dict, list, tuple with headers or status, Response instance, or WSGI callable, but it was a Response.代码是这个:@app.route('/get_nb2_ip/') def get_nb2_ip(): #curl -i --basic -u admin:public -X GET "http://192.168.34.131:8081/api/v4/clients?_page=1&_limit=10" response = requests.get('http:192.168.34.131:8081/api/v4/clients?_page=1&_limit=10', auth=('admin', 'public')) return response