Install mod_python

Nancy wxling3 at hotmail.com
Sun Jul 18 09:16:50 EDT 2004


vincent wehren <vincent at visualtrans.de> wrote in message news:<cdd906$4mg$1 at news5.tilbu1.nb.home.nl>...
> Nancy wrote:
> > Hi,
> >  I am new to python. I am trying to install mod_python in my
> > computer(WinXP Pro, Apache 2.0.50, python2.3.4). I added the following
> > statements in my Apache configuration file httpd.conf
> > 
> > <Directory "C:/Apache Group/Apache2/htdocs/python">
> >     AddHandler python-program .py
> >     PythonHandler myscript
> > </Directory>
> > 
> > LoadModule python_module modules/mod_python.so
> > 
> > And restart my Apache. edit myscript.py as following and put the file
> > in the directory of C:/Apache Group/Apache2/htdocs/python/,
> > 
> > from mod_python import apache
> >  def handler(req):
> >   req.content_type = "text/plain"
> >   req.send_http_header()
> >   req.write("Hello World!")
> >  return apache.OK
> > 
> > but it gives following error message:
> > The server encountered an internal error or misconfiguration and was
> > unable to complete your request.
> > 
> > The error.log shows as,
> > 
> > [Sat Jul 17 23:26:37 2004] [error] [client 127.0.0.1] PythonHandler
> > myscript: Traceback (most recent call last):
> > [Sat Jul 17 23:26:37 2004] [error] [client 127.0.0.1] PythonHandler
> > myscript:   File "C:\\Python23\\Lib\\site-packages\\mod_python\\apache.py",
> > line 287, in HandlerDispatch\n    log=debug)
> > [Sat Jul 17 23:26:37 2004] [error] [client 127.0.0.1] PythonHandler
> > myscript:   File "C:\\Python23\\Lib\\site-packages\\mod_python\\apache.py",
> > line 457, in import_module\n    module = imp.load_module(mname, f, p,
> > d)
> > [Sat Jul 17 23:26:37 2004] [error] [client 127.0.0.1] PythonHandler
> > myscript:   File "C:/Apache
> > Group/Apache2/htdocs/python/\\myscript.py", line 2
> > [Sat Jul 17 23:26:37 2004] [error] [client 127.0.0.1] PythonHandler
> > myscript:     def handler(req):
> > [Sat Jul 17 23:26:37 2004] [error] [client 127.0.0.1] PythonHandler
> > myscript:     ^
> > [Sat Jul 17 23:26:37 2004] [error] [client 127.0.0.1] PythonHandler
> > myscript: SyntaxError: invalid syntax
> > 
> >  Who could give me some hints? Thanks a lot!
> > 
> > Nancy Wang
> 
> Looks like you got your indentation wrong. What happens if you try the 
> following instead:
> 
> from mod_python import apache
> 
> def handler(req):
>      req.content_type = "text/plain"
>      req.send_http_header()
>      req.write("Hello World!")
>      return apache.OK
-----

Yes, my indentation was wrong. Thank you very much!

Nancy



More information about the Python-list mailing list