1

I currently have a small webapp on AWS based on the MEAN (Mongo, Express, Angular, Node) but have a python script I would like to execute on the front end. Is there a way to incorporate this? Basically, I have some data objects on my AngularJS frontend from a mongoDB that I would like to manipulate with python and don't know how to get them into a python scope, do something to them, and send them to a view.

Is this possible? If so, how could it be done? Or is this totally against framework conventions and should never be done?
from

abgordon
  • 667
  • 1
  • 6
  • 16
  • One idea that comes to mind is to connect the python script using one of the many mogodb --> python connectors and then call the python script from your node application see (http://stackoverflow.com/questions/20972788/how-to-invoke-external-scripts-programs-from-node-js). – Jake C. Apr 27 '15 at 19:06

1 Answers1

1

To answer my own question about a year later, what I would do now is just run my python script in tiny web server that lived on the same server as my MEAN app. It wouldn't have any external ports exposed and the MEAN app would just ping it for information and get JSON back. Just in case anyone is looking at this question down the road...

I find this way easier than trying to integrate the python script into the application itself.

abgordon
  • 667
  • 1
  • 6
  • 16
  • Can you please provide code and details of your answer – Ragy Isaac Apr 10 '17 at 13:53
  • Hey, sorry but the git repo that lived on is closed now. But essentially it's the pattern of a microservice. A flask app would do the trick I think: just set up a simple endpoint on the same node and execute the python code you desire to use – abgordon Apr 10 '17 at 17:46