
How to run PHP with Python using a RESTful API
by bernt & torsten
During development, I set up a virtual environment, here is how I did that.
virtualenv
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 python
Run the rest-server
$ python rest-server.py &
You can test it
curl -X GET http://127.0.0.1:5000/api/v1.0/test
or
http://localhost:5000/api/v1.0/test
Now time to send a test message to Luminoso
curl -H “Content-type: application/json” -X POST http://127.0.0.1:5000/api/v1.0/luminoso -d ‘{“message”:”test”}’

The Human Brain and Its Role in Creativity, Memory, and AI
The human brain is a marvel of evolution, a universe within, teeming with thoughts, memories,...

What’s the Environmental Cost of Your Online Activities? From AI Queries to Streaming Video
Scrolling through social media, searching on Google, or chatting with an AI feels like a...

A Poem: Too Old to Be Seen, Too Wise to Be Broken
They saw my years, not the code I wrote,
Dismissed the knowledge I carried, remote.