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


Groups > comp.lang.python > #43653

Python with Apache

Path csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <renato.barbosa.pim.pereira@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.016
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'else:': 0.03; 'modified:': 0.05; 'subject:Python': 0.06; 'cache': 0.07; 'error:': 0.07; 'skip:/ 10': 0.09; "'user'": 0.16; '.py': 0.16; 'arg,': 0.16; 'help?': 0.16; 'instance:': 0.16; 'subject:Apache': 0.16; 'to:name:python list': 0.16; 'module': 0.19; 'trying': 0.19; 'import': 0.22; 'error': 0.23; 'form:': 0.24; 'parse': 0.24; 'installed': 0.27; 'skip:p 30': 0.29; 'raise': 0.29; 'skip:& 60': 0.30; 'message-id:@mail.gmail.com': 0.30; "skip:' 10": 0.31; 'cgi': 0.31; 'file': 0.32; 'skip:c 30': 0.32; '(most': 0.33; 'skip:# 10': 0.33; 'skip:& 30': 0.33; 'skip:_ 10': 0.34; 'skip:d 20': 0.34; 'subject:with': 0.35; 'received:209.85': 0.35; 'created': 0.35; 'received:209.85.220': 0.35; 'received:google.com': 0.35; 'skip:" 50': 0.36; 'entry': 0.36; 'received:209': 0.37; 'skip:& 10': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'skip:_ 30': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'blank': 0.60; 'skip:c 50': 0.60; 'skip:\xc2 10': 0.60; 'location:': 0.61; 'browser': 0.61; 'happen': 0.63; 'details': 0.65; 'reply': 0.66; '8bit%:100': 0.72; 'directory:': 0.84; 'skip:/ 30': 0.84; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=ClRtdZraIehdsUqyaA3elf7YDt3PwETSqIzNzbJt1Jo=; b=cNnMxb4ar/gIlS6xFJ5rb7TLPek+yrFkjgn8xM6W12mbvXItXtF8k1nUqNLB3bpTWA XLLfGmr3np75vk1CChX+e0Pzbsv5aWZ80FvsRTmzuaLl5CTOSM31atxs7LbVFFQgul/Q fY/g220S4kB0VFGRiGQbLohTTy2aNFa8dYAtc477P74otMFqnf85nUE0+YV9aZCmOvyD jEyldMIR0Ls3xiYTia1YrsFPeyQ22z9c1hHJlbu2jNL3yGjn+ff59rT6wHS1pq4eWp3L t8NTNCA6086K52uo8HhxXaf20jlYZrCVnJ5pqYDGUWCwNEXeQbcTQaYh/IVvEQTfFS7B dU8Q==
MIME-Version 1.0
X-Received by 10.52.89.229 with SMTP id br5mr173405vdb.24.1366077730420; Mon, 15 Apr 2013 19:02:10 -0700 (PDT)
Date Mon, 15 Apr 2013 23:02:10 -0300
Subject Python with Apache
From Renato Barbosa Pim Pereira <renato.barbosa.pim.pereira@gmail.com>
To python list <python-list@python.org>
Content-Type multipart/alternative; boundary=20cf307f3762dbb1e804da70c1a9
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.653.1366077739.3114.python-list@python.org> (permalink)
Lines 158
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1366077739 news.xs4all.nl 2633 [2001:888:2000:d::a6]:47926
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:43653

Show key headers only | View raw


[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
}

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web