Yes, it is possible using
childprocess
core module. You need to call your
Python
script from
Node.js
which will store the output of your Python script and you can do whatever you want with the variable post it.
An example from
web[
^] is:
const express = require('express')
const app = express()
app.get('/', (req, res) => {
const { spawn } = require('child_process');
const pyProg = spawn('python', ['./../pypy.py']);
pyProg.stdout.on('data', function(data) {
console.log(data.toString());
res.write(data);
res.end('end');
});
})
app.listen(4000, () => console.log('Application listening on port 4000!'))
Detailed step-by-step to set it up can be followed here:
https://medium.com/swlh/run-python-script-from-node-js-and-send-data-to-browser-15677fcf199f[
^]