Forums

php communicate with the python app

Is there a simple way for php on another server to communicate with my python anywhere app?

Hi there, there are different ways of achieving that and it will depend on the setup of your application. I'd suggest you have a look at some resources online first, and we can help out if you have any more specific questions. In general, we can offer better support when it comes to Python related issues :)

Wow, great idea I never thought of that. Are you seriously suggesting I started with this post? If there are several ways, why don't you simply share a concepts so I can look at those ways?

I have a "hello world" app working with a form that submits a number of years of work experience and predicts a salary with a pickled model. I am trying to bypass the form with php and work directly with the app to get a prediction. I tried CURL but get a bad request (or proxy) sent a request that this server could not understand. Despite what "nkahr" suggests above, I have read numerous articles and see nothing to help php get data form an app. I have a lot of python and php experience but am new to WSGI.

So I really need the app to accept some input from and return output the can be CURLed or otherwise consumed by the php.

Any help will be appreciated.

You asked very general question and so you got very general answer.

We can help you with PythonAnywhere services, but we are not able to solve problems with php.

Does your web app work in the browser?

Go read the internet is not an answer. I will figure it out as I do not have time for your cuteness.

cURL is now working to get data from my python app. The issue was that the html form in my app used the variable value="predict" so I was passing the the variable name "predict" with the php cURL POST like my form did. The form worked in the app but not the cURL - bad request (or proxy) sent a request that this server could not understand.

The python script used the variable name "exp" so I changed the php cURL POST variable name to "exp" and it worked. Unclear why "predict" variable worked on the form and not the cURL. Hope this saves someone some time.

Apologies for being curt.