How to run PHP with Phyton using a RESTful API

During development I setup a virtual environment, here is how I did that.


If you are on Mac OS X or Linux, chances are that one of the following two commands will work for you:

$ sudo easy_install virtualenv
or even better:

$ sudo pip install virtualenv

Once you have virtualenv installed, just fire up a shell and create your own environment. I usually create a project folder and a venv folder within:

$ mkdir myproject
$ cd myproject
$ virtualenv venv
New python executable in venv/bin/python
Installing distribute…………done.
Now, whenever you want to work on a project, you only have to activate the corresponding environment. On OS X and Linux, do the following:

$ . venv/bin/activate
If you are a Windows user, the following command is for you:

$ venv\scripts\activate
Either way, you should now be using your virtualenv (notice how the prompt of your shell has changed to show the active environment).

Now you can just enter the following command to get Flask activated in your virtualenv:

$ pip install Flask
A few seconds later and you are good to go.

As I’m going to use the Luminoso Python client, I need to install it

$ pip install luminoso_api

Now it is time to write the rest server in pyhton

Run the rest-server
$ python &

You can test it

curl -X GET



Now time to send a test message to Luminoso
curl -H “Content-type: application/json” -X POST -d ‘{“message”:”test”}’