How to run a NodeJS app in collaboration with python

Hi. I am trying to run a NodeJS server on glitch that uses child_process to call and execute a Python script locally and log the info. Unfortunately the server can’t execute the script.

Please if there is anyway I could do that I will like to know.

Thanks

Have you tried something like:

const { exec } = require("child_process");

exec("python3 myscript.py", (error, stdout, stderr) => {
    if (error) {
        console.log(`error: ${error.message}`);
        return;
    }
    if (stderr) {
        console.log(`stderr: ${stderr}`);
        return;
    }
    console.log(`stdout: ${stdout}`);
});

this?

7 Likes