<div dir="ltr"><div><div><div>I am trying to execute cgi101.py:<br><br>#!/usr/bin/python
<br> <br>import cgi
<br> <br>form = cgi.FieldStorage() # parse form data
<br>print('Content-type: text/html\n') # hdr plus blank line
<br>print('<title>Reply Page</title>') # html reply page
<br>if not 'user' in form:
<br> print('<h1>Who are you?</h1>')
<br>else:
<br> print('<h1>Hello <i>%s</i>!</h1>' % cgi.escape(form['user'].value))<br><br></div>I have installed mod_python do apache2 and created one entry in /etc/apache2/sites-available/default:<br>
<br> DocumentRoot /var/www<br> <Directory /var/www/py/><br> AddHandler mod_python .py<br> PythonHandler cgi101<br> PythonDebug On<br> </Directory><br><br></div><div>
What. happen is: when i call this file on browser I have the following error:<br></div>
Can someone help?<br></div><br><pre>MOD_PYTHON ERROR
ProcessId: 2742
Interpreter: '127.0.1.1'
ServerName: '127.0.1.1'
DocumentRoot: '/var/www'
URI: '/py/cgi101.py'
Location: None
Directory: '/var/www/py/'
Filename: '/var/www/py/cgi101.py'
PathInfo: ''
Phase: 'PythonHandler'
Handler: 'cgi101'
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)
File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1206, in _process_target
object = apache.resolve_object(module, object_str, arg, silent=silent)
File "/usr/lib/python2.7/dist-packages/mod_python/apache.py", line 696, in resolve_object
raise AttributeError, s
AttributeError: module '/var/www/py/cgi101.py' contains no 'handler'
MODULE CACHE DETAILS
Accessed: Mon Apr 15 22:02:42 2013
Generation: 0
_mp_63ea7b6576c7d3a5f48ef8741e8048b0 {
FileName: '/var/www/py/cgi101.py'
Instance: 1 [IMPORT]
Generation: 1
Modified: Mon Apr 15 21:52:27 2013
Imported: Mon Apr 15 22:02:42 2013
}<br><br><br></pre></div>