Design questions (cgi programming with python)
Levente Sandor
sandorlevi at yahoo.com
Thu Dec 26 12:36:08 EST 2002
You might want to use something like this:
#!/usr/bin/python
import cgi
form = cgi.FieldStorage()
# I assume that your submit button's value was "Submit"
if form.has_key("Submit"):
# process the submitted data
# ... your code here ...
else:
print "Content-type: text/html\n\n"
# ... print your HTML code here ...
----
Levi
"Paul" <anon at nowhere.org> wrote in message news:<pan.2002.12.25.22.54.54.458661 at nowhere.org>...
> 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).
> 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....)
>
> import cgi
> .....
>
>
> many thanks for reading!
> Merry Christmas!
More information about the Python-list
mailing list