954,541 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Python CGI error

I have this html:

<html>
<body>
<form action='super.py'>
<input type=text name=person value="New User" size = 15>
<input type=submit></form>
</body>
</html>

& this python script:

<html>
<body>
<form action='super.py'>
<input type=text name=person value="New User" size = 15>
<input type=submit></form>
</body>
</html>
matio@matio-desktop:~$ cat /var/www/py/super.py 
#!/usr/bin/env python

import cgi

rehtml = '''Content-Type: text/html\n
<html><body>
Your name is %s
</body>
</html>
'''
form = cgi.FieldStorage()
who = form['person'].value
print reshtml % (who)

when i click submit:

MOD_PYTHON ERROR

ProcessId:      14109
Interpreter:    '127.0.1.1'

ServerName:     '127.0.1.1'
DocumentRoot:   '/var/www'

URI:            '/py/super.py'
Location:       None
Directory:      '/var/www/py/'
Filename:       '/var/www/py/super.py'
PathInfo:       ''

Phase:          'PythonHandler'
Handler:        'hello'

Traceback (most recent call last):

  File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1537, in HandlerDispatch
    default=default_handler, arg=req, silent=hlist.silent)

  File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1202, in _process_target
    module = import_module(module_name, path=path)

  File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 304, in import_module
    return __import__(module_name, {}, {}, ['*'])

ImportError: No module named hello

whats wrong?

pymatio
Light Poster
48 posts since Jun 2009
Reputation Points: 10
Solved Threads: 0
 

As a side note, "super" is a reserved keyword in Python already, and you named your script that. It shouldn't cause this problem at all but in the future it might raise some sort of issue if you expand on this.

As for the current situation, what was the value you typed into the textbox in the HTML form? Was it "hello"?

shadwickman
Posting Pro in Training
497 posts since Jul 2007
Reputation Points: 186
Solved Threads: 77
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You