Solution 1 :

If you’re already executing the Python script as a child process, simply capture the STDOUT stream from the process.

https://nodejs.org/api/child_process.html

https://nodejs.org/api/child_process.html#child_process_subprocess_stdout

Solution 2 :

I do not have comment privileges yet and this may not be an exact answer but have you looked into websockets? It looks like you should be able to emit the data from the python code to the port that you may be hosting your web page on.

Problem :

I currently have a simple HTML with three input text boxes and a button running on Node.js. I am able to send values from the HTML page to the python script as arguments when executing the script (sys.argv) through Node.js as a child process.

The python script keeps generating values. Right now, I simply print those values, but can I grab these values and send them back to the webpage every second until the script stops running after about 3 minutes? If yes, how can I grab them?

I want to use Node.js because I want to use the package pdfmake (https://www.npmjs.com/package/pdfmake) from npm to generate reports of the same.

Comments

Comment posted by stackoverflow.com/questions/60407826/merge-two-codes

Try this may be this can help you..

By