I am developing a small part of a PHP application with some python code. The python code runs like an equivalent of a servlet (listens and responds to HTTP on port 8765) on localhost. The PHP app calls it like:
PHP'S_CURL("http://localhost:8765/search?term=electrical+design")
The pyth-let is written with the BaseHTTPServer module like:
class MyHandler(BaseHTTPRequestHandler):
def do_GET(self):
if self.path=="/search":
self.send_response(200)
# ....
self.wfile.write(st)
It works on my workstation and my colleague’s. I now want to deploy it in a production environment, with modifications. The idea in mind is that I should:
- modify my app to FCGI
- get an inexpensive VPS account
- set Apache to use FCGI to spawn and keep alive both the PHP app and the pyth-let.
So it’s a localhost app, which shouldnt be exposed publically. There should be reliable way to keep it alive. We expect ~800 hits a day before needing an upgrade, so only a single instance need be kept alive.
Is there a feasible way to do this on a popular shared host, rather than a VPS? Am I on the right track with my above-mentioned plan?
Postscipts
I mentioned “easy, reliable, cheap way”
and by “way” I meant both the development direction as well as a good (cheap) hosting plan that can support it.
You can use flup to serve your python app with fastcgi. I’ve also used gunicorn to deploy python webapps along with supervisor and found that to be a good approach – and even easier to setup.