2

I'm launching a python script like this with nodejs :

var cp = require('child_process');
var spw = cp.spawn('python', ['tql.py']),


spw.stdout.on('data', function (data) {
   console.log(data);
});

spw.on('close', function (code) {
   console.log("Script ended");
});

spw.stderr.on('data', function (data) {
   console.log('stderr: ' + data);
});

Knowing that this code is inside a javascript file that is included in an html page and there is a progressbar element inside it, is there a way to update the progressbar according to the time of execution of the python script ?

DeseaseSparta
  • 271
  • 2
  • 4
  • 12
  • execSync means "do it synchronous" so you have to wait for the end to get theoutput, probably you could check this https://www.npmjs.com/package/spawn-async – michelem Nov 19 '15 at 11:49
  • Just want to make this clear - you cannot use javascript running in a web page to execute things on the server. The script above will run on the server using node, right? So you can hook up the `data` events with something like websockets or server-sent events to interact with a progress element in the web browser. – Linus Thiel Dec 21 '15 at 22:35
  • Yes, it's on the server side. So do I have to define my own datas on the python script to define how to progress the bar ? – DeseaseSparta Dec 22 '15 at 09:02

0 Answers0