web server in python
graham__fawcett at hotmail.com
Thu Apr 3 19:08:26 CEST 2003
"Tom Saunders" <toms at f2s.com> wrote in message news:<b6gnau$d7q$1 at news.freedom2surf.net>...
> i am curerntly trying to make simple dynamic site in python which i intend
> to expand on. i can make the html using python but i have a few questions.
> using the BaseHTTPServer class, is it then possible to write all the code
> for a site inside one python program, which then serves based on requests
> from a website?
> ive been having trouble finding information about this and i would be
> greatfull if someone could give me an example of how to start.
> Hope you can help
It's possible to write a BaseHTTPRequestHandler subclass that will let
you "write all the code for a site in one python program". You can
write a do_GET() method that can look at the request URI and, based on
what was requested, dispatch the request to a specific handler. So if
you ask for the page 'http://localhost/hello', your do_GET method
might call your do_hello() method to fulfill the request. Your do_POST
method could dispatch your form-submission requests in a similar
But you will end up writing a lot of support code that others have
already provided for you (for free).
There's an excellent list of Python Web Programming tools at:
Check out the Application Frameworks section in particular. Not all of
these tools will meet your "one file only" criterion, but many will.
More information about the Python-list