Newbie: A very basic problem related to cgi.py
Ali
ali.jan at gmail.com
Mon Dec 20 08:48:01 EST 2004
Hello all,
I have got a very simple python code:
___________________________
#!/usr/bin/python
import cgi
def main():
print "Content-type: text/html\n"
form = cgi.FieldStorage()
if form.has_key("firstname") and form["firstname"].value != "":
print "<h1>Hello", form["firstname"].value, "</h1>"
else:
print "<h1>Error! Please enter first name. </h1>"
main()
__________________________
I try to run this form the command line (I am on linux) just to check
it out and it gives me the following errors/output:
__________________________
Content-type: text/html
Traceback (most recent call last):
File "./mycgi.py", line 2, in ?
import cgi
File "/usr/lib/python2.3/cgi.py", line 12, in ?
"""Support module for CGI (Common Gateway Interface) scripts.
File "/usr/lib/python2.3/cgi.py", line 6, in main
# scripts, and /usr/local/bin is the default directory where Python
is
AttributeError: 'module' object has no attribute 'FieldStorage'
__________________________
Is it reasonable to infer from the above that cgi.py module has been
loaded successfully? because if it is, why on earth am i getting the
error for FieldStorage??
I think i am missing something very basic here... plese enlighten...
Thanks
More information about the Python-list
mailing list