【发布时间】:2019-01-06 07:52:58
【问题描述】:
我正在使用 python shell 在 nodeJS 上运行 python。我需要返回 python shell 作为响应。但是当我尝试发送响应时它显示错误
Can't set headers after they are sent.
这是我的代码
app.post('/therun', (req, res)=>{
var pyshell = new PythonShell('hello.py');
pyshell.on('message', function (message) {
console.log(message); //value is correct
res.send(message); //error here
});
res.send(message); //if i use here message undefined
});
如何解决这个问题?
【问题讨论】:
标签: python json node.js angular flask