Design questions (cgi programming with python)

Bengt Richter bokr at oz.net
Thu Dec 26 09:18:42 EST 2002


On Wed, 25 Dec 2002 22:54:59 +0000, "Paul" <anon at nowhere.org> wrote:

>I have to learn python in order for my uni project to progress.  It's
>basically an e-learning website engine.  It has to be (ideally)one cgi file which
>produces the initial page(with links for creating a new account, or
>logging in).  Then, it has to process logins etc.
>
>So, i;m having some trouble getting this done....i'm going to practice by
>writing html output into the browser, along with a form who's action tag
>points to the same script that generates the form itself.  I've done
>similar things in C previously. (using the QUERY_STRING variable).
So perhaps you should think about looking at that variable and others
via, e.g., os.getenv('QUERY_STRING') and control what your program prints like
you did in C. Is this homework? ;-)

>I've got a sample page rendering in a browser, but how can I get the program to
>not re-display the initial page, and just process the cgi.
>
>---------
>#!/usr/bin/python
>print "Content-type: text/html\n\n"
>
>print """
><html>
>....
></html>
>"""
>#(^^^that is always re-done when the html form is processed....)
If you make stuff unconditional, it's going to be done unconditionally ;-)
Where are the ifs ?
>
>import cgi
>.....
>
>
>many thanks for reading!
>Merry Christmas!
You too ;-)

Regards,
Bengt Richter



More information about the Python-list mailing list