Start New Discussion within our Software Development Community

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?

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"?

This article has been dead for over six months. Start a new discussion instead.