Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #43653 > unrolled thread

Python with Apache

Started byRenato Barbosa Pim Pereira <renato.barbosa.pim.pereira@gmail.com>
First post2013-04-15 23:02 -0300
Last post2013-04-15 23:02 -0300
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Python with Apache Renato Barbosa Pim Pereira <renato.barbosa.pim.pereira@gmail.com> - 2013-04-15 23:02 -0300

#43653 — Python with Apache

FromRenato Barbosa Pim Pereira <renato.barbosa.pim.pereira@gmail.com>
Date2013-04-15 23:02 -0300
SubjectPython with Apache
Message-ID<mailman.653.1366077739.3114.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

I am trying to execute cgi101.py:

#!/usr/bin/python

import cgi

form = cgi.FieldStorage()                 # parse form data
print('Content-type: text/html\n')        # hdr plus blank line
print('<title>Reply Page</title>')        # html reply page
if not 'user' in form:
    print('<h1>Who are you?</h1>')
else:
    print('<h1>Hello <i>%s</i>!</h1>' % cgi.escape(form['user'].value))

I have installed mod_python do apache2 and created one entry in
/etc/apache2/sites-available/default:

    DocumentRoot /var/www
    <Directory /var/www/py/>
            AddHandler mod_python .py
            PythonHandler cgi101
            PythonDebug On
        </Directory>

What. happen is: when i call this file on browser I have the following
error:
Can someone help?

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
}

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web