1

We using AngularJS as a frontend for our web application and some of the functions we are using python to do the calculation and get results back.

I would like to know is there any way to calling the python script directly in AngularJS? right now we are using $HTTP service to call PHP then in PHP using EXEC command to call the python, it is all working fine.

The problem is we notified there is about 5 seconds delay every time the python script call and I guess it is because of the overhead for the python interpreter and try to start it every time, we would like to eliminate that delay.

We are run on Redhat v 6.8 / AngualarJS 1.4x and Python 3.6 Anaconda3

Does anyone try something like that? any suggestions are welcome.

Thank you!

1 Answer 1

3

You could write a python method that calls your calculation code and expose that method as a REST API.

You would need a library like Flask.

This tutorial explains how to do that : https://www.codementor.io/sagaragarwal94/building-a-basic-restful-api-in-python-58k02xsiq

This way you can directly call the python API.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.