Flask-脚本'app.cgi'中格式错误的标头:标头错误 [英] Flask - malformed header from script 'app.cgi': Bad header
问题描述
我正在对Flask
中的python
脚本进行AJAX
调用. python脚本通过jsonify
返回响应对象.
I am making an AJAX
call to my python
script in Flask
. The python script is returning a response object through jsonify
.
python
脚本部署在Apache24
中.
return jsonify({"responseList": response}) # here response is a list
在我的Web浏览器中,我收到错误-500-内部服务器错误.
在Apache日志中,我看到此错误malformed header from script 'app.cgi': Bad header
In my web browser I get the Error - 500 - Internal server error.
In the Apache logs, I see this error malformed header from script 'app.cgi': Bad header
I read here that we need to give a new line between the header and the body to avoid this error. Is that really needed with jsonify
or is there a way to give a new line, as jsonify
adds the header on its own.
请提出建议. 谢谢.
推荐答案
我相信您需要按如下所示编写返回行:
I believe you need to write your return line as follows:
import Response from flask
import json
...
return Response(json.dumps({"responseList": response}), mimetype='application/json')
这篇关于Flask-脚本'app.cgi'中格式错误的标头:标头错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!