【发布时间】:2020-03-23 23:49:28
【问题描述】:
我有这段代码。如果它是真的,它应该调用我的 python 脚本。
问题是:脚本没有被执行。我正在使用 Heroku,并且我的 buildpack 中已经有了 nodejs 和 python。
const express = require('express');
const bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
let {PythonShell} = require('python-shell');
app.post('/api/apipath', (req, res) => {
if (currentPhase == phaseId){
PythonShell.run('./src/main.py', null, function (err){
if (err) throw err;
console.log('Finish');
});
res.end();
}else{
res.end();
}
}
注意:我已经强制条件为真,但它不起作用。脚本没有被调用
【问题讨论】:
-
当你说“没有被执行”时,究竟发生了什么?代码是否真的在尝试执行脚本,或者
currentPhase总是与phaseId不同? -
我已经强制条件为真,但它不起作用。该脚本未被调用