Calling a python script with a javascript file? It doesn’t seem to return anything. via /r/learnprogramming


Calling a python script with a javascript file? It doesn’t seem to return anything.

I tried to use this tutorial here

http://ift.tt/2vadeyU

so the file I have in javascript/node looks like

app.get('/myInput/:input', function(req, res){

console.log(req.params.input) var spawn = require("child_process").spawn var process = spawn('python',["(path)\test2.py", req.params.input]); process.stdout.on('data', function(data){ console.log(data); }); 

});

and it prints out input to console. So that's working. And my python file is:

Input = sys.arv[1]

print(Input)

sys.stdout.flush()

so it should return the input to the javascript file and then print it out. So it should print the input twice. But it doesn't. Anyone have any ideas why not?

This is running on a localhost windows 10 machine.

Submitted July 17, 2017 at 12:42PM by Venne1138
via reddit http://ift.tt/2vuzqmZ

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s