P
P
polyakovyevgeniy2017-04-09 13:32:01
Python
polyakovyevgeniy, 2017-04-09 13:32:01

How to call a Python function from Node.js and vice versa?

How can one call a function in nodejs from Python and vice versa from a nodejs function call a function in Python?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Cheremisin, 2017-04-09
@polyakovyevgeniy

Why call each other? Both are server languages, both can act as a web server. So make two microservices, in python and node, and let them shoot at each other with data.

V
Vitaly, 2017-04-09
@vshvydky

const spawn = require('child_process').spawn;
const ls = spawn('ls', ['-lh', '/usr']);

ls.stdout.on('data', (data) => {
  console.log(`stdout: ${data}`);
});

ls.stderr.on('data', (data) => {
  console.log(`stderr: ${data}`);
});

ls.on('close', (code) => {
  console.log(`child process exited with code ${code}`);
});

more
here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question