[Tutor] Python cgi doesn't get data from html form as expected

Michael Lasky mlasky1 at cox.net
Tue Mar 22 16:21:05 CET 2005


I haven't done too much web stuff (or much of anything) with python, but
I looked into your question a bit (researching other's problems may help
me avoid them =)).  A quick search brought up this page which seems to
have information which may help you.

http://gnosis.cx/publish/programming/feature_5min_python.html

Hope that helps. 
Best Regards,
Michael Lasky

On Tue, 2005-03-22 at 14:02 +0000, Vicki Stanfield wrote:
> I have recently started doing cgi in Python and have run into a problem. I
> have an html form which has various widgets which accept data. I also have
> this in that html file:
> 
> <form action="formdata.py" method="post">
> 
> formdata.py runs but doesn't seem to contain the data from the form. I'm
> not sure of the format for the for with regard to FieldStorage btw. Here
> is the contents of formdata.py:
> 
> ----------------
> #! /usr/bin/python
> import cgitb, os, sys
> cgitb.enable()
> 
> import cgi
> 
> print "Content-Type: text/html\n\n"
> print "<html><head></head><body>"
> form = cgi.FieldStorage()
> for each in form:
>         print "each"
> print form['fname'].value, form['lname'].value
> #print "address:", form['addr'].value()
> print "</body></html>"
> ------------------
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor



More information about the Tutor mailing list