-1

I have a Flask Web Application that is periodically receiving JSON information from another application via HTTP POST.

My Flask Web Application is running on a CentOS 7 Server with Python 2.7.X.

I am able to parse the fields from this received JSON in the Flask Web Application and get some of the information that interests me. For example: I get some JSON input and extract an "ID":"7" field from it.

What I want to do now is run a perl script from within this Flask Web Application by using this "ID":"7".

Running 'perl my_perl_script.pl 7' manually on the command line works fine. What I want is for the Flask Web Application to perform this automatically whenever it receives an HTTP POST, by using the specific ID number found in this POST.

How can I do that in Flask? Is it a good idea to do it with a subprocess call or should I consider implementing queues with Celery/rq? Or maybe some other solution?

I think the perl script should be invoked as a separate Linux process, independent of the Flask Web Application.

Thank you in advance :)

1 Answers1

1

Sub,

I vote yes on subprocess, here's a post on SO about it. Control remains with Flask that way. An alternative might be to code a perl script that watchdogs for a trigger event depending on your needs, but that would put more of the process control on the perl side of things and less efficient use of resources.

Geoff W.
  • 11
  • 4