I have this piece of code. It should call my python script if it is true.
The problem is: the script doesn't get executed. I'm using Heroku and I already have nodejs and python in my buildpacks.
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();
}
}
Note: I already forced the condition to be true and it didn't work. The script was not called
currentPhasealways different fromphaseId?