CherryPy claims:
Your CherryPy powered web applications
are in fact stand-alone Python
applications embedding their own
multi-threaded web server. You can
deploy them anywhere you can run
Python applications. Apache is not
required, but it’s possible to run a
CherryPy application behind it (or
lighttpd, or IIS). CherryPy
applications run on Windows, Linux,
Mac OS X and any other platform
supporting Python.
Having come from PHP and wanting to learn Python, I came upon a thread here in SO while looking for a webserver I can setup to start Python web development. However, after almost googling myself to death, I can’t still find one. I came across entries like “Django has its own lightweight webserver” and the aforementioned Cherrypy.
What I am confused about is this :I was used to using XAMPP, where I have a web server, a database server and my application and I can’t visualize the idea of a “web server inside the application itself”. How do I connect to my database server then? How do I configure stuff like custom urls and directory protection (much like what I do in Apache)?
Thanks in advance guys!
Apache is a large, rich, powerful and complicated webserver — you can configure everything and a half, there are many plug-in modules (all the various
mod_this,mod_that, etc), and so forth. That’s great, but of course there are niches for smaller, lighter webservers as well —lighttpd(which your cherrypy quote mentions) is an example of one, focusing on speed and simplicity; cherrypy is another, focusing on simplicity and Python support.Of course you can still configure several aspects, see the tutorial section about the configuration files for a short overview, the reference for more details — but it won’t be anywhere as rich as Apache (hey, few webservers are, except maybe IIS;-). Probably some configuration options that you may feel are missing may be easily compensated with Python code, but not all — that’s why you may want to run cherrypy “behind” other servers!
The way you code your Python web apps need not be constrained by the web server you’re using: just program to the WSGI standard (and that’s what just about all web app frameworks these days support), and your deployment options are boundless — from cherrypy, or even just the reference wsgi implementation that comes with the Python standard library (only recommended for development!-), all the way to Apache with
mod_wsgi, IIS, even Google App Engine (it supports WSGI, too!-).