where do I begin with web programming in python?

George Sakkis george.sakkis at gmail.com
Thu May 1 19:50:20 EDT 2008


On May 1, 7:13 pm, Graham Dumpleton <Graham.Dumple... at gmail.com>
wrote:
> On May 2, 7:45 am, Christian Heimes <li... at cheimes.de> wrote:
>
>
>
> > jmDesktop schrieb:
>
> > > I have been to the main python site, but am still confused.  I have
> > > been using .net, so it may be obvious how to do this to everyone
> > > else.  I am aware there are various frameworks (Django, Pylons, etc.),
> > > but I would like to know how to create web pages without these.  If I
> > > havemod_pythonor fastcgi on apache, where do I start?  I don't have
> > > clue where to begin to create a web page from scratch in python.  I am
> > > sure I will want to access database, etc., all the "normal" stuff, I
> > > just want to do it myself as opposed to the frameworks, for learning.
>
> > I highly recommend WSGI instead ofmod_pythonor (fast)cgi. I've heard
> > only bad things aboutmod_pythonover the past years and CGI is totally
> > old school.
>
> > Check out Python Paste, CherryPy and Django. You can also try the Zope,
> > Zope3 and Plone world but Zope is usually for larger and complex
> > applications.
>
> > Most frameworks come with their own little web server for development, too.
>
> I'd also suggest avoiding coding anything directly to mod_python and
> instead base things on WSGI. You can still run it on mod_python with a
> suitable adapter, but you can also run it with mod_wsgi, mod_fastcgi,
> or using pure Python web servers such as the one in Paste as well.
>
> For a low level nuts and bolts (anti framework) approach I'd suggest
> looking at:
>
>  http://dev.pocoo.org/projects/werkzeug/
>
> This gives you all the basic components, but it is really up to you as
> to how you put them together, which seems to be what you want to be
> able to do.

Or if you don't want to use any 3rd party package and have Python 2.5,
you may start from http://www.xml.com/pub/a/2006/09/27/introducing-wsgi-pythons-secret-web-weapon.html.
Here's the standard "Hello world!" example:

from wsgiref.simple_server import make_server

def application(environ, start_response):
    start_response('200 OK',[('Content-type','text/html')])
    return ['<html><body>Hello World!</body></html>']

httpd = make_server('', 8000, application)
print "Serving HTTP on port 8000..."
httpd.serve_forever()

and point your browser to http://localhost:8000/

HTH,
George



More information about the Python-list mailing list