A. Hilbert
A. Hilbert

Reputation: 23

How to invoke python scripts in node.js app on Bluemix?

I'd like to run text processing Python scripts after submitting searchForms of my node.js application.

I know how the scripts can be called with child_process and spawn within js, but what should I set up on the app (probably some package.json entries?) so that it will be able to run Python after deploying to Bluemix?

Thanks for any help!

Upvotes: 1

Views: 362

Answers (2)

A. Hilbert
A. Hilbert

Reputation: 23

I finally fixed this as adding an entry to dependencies in package.json of the project, which causes the call of npm install for the linked github repo. It is kinda straightforward but I found no explanation for that on Bluemix resources.

Upvotes: 1

Ben Rondeau
Ben Rondeau

Reputation: 3053

There is a helpful library called python-shell you can use. Here is a basic example of its usage:

var PythonShell = require('python-shell');

PythonShell.run('my_script.py', function (err) {
  if (err) throw err;
  console.log('finished');
});

There are 100 other ways to do this, but this is likely the easiest.

Hope this helps

Upvotes: 0

Related Questions