469,312 Members | 2,493 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,312 developers. It's quick & easy.

Install mod_python

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
Jul 18 '05 #1
3 2237
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:

Looks 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
Jul 18 '05 #2
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

--
Vincent
Jul 18 '05 #3
vincent wehren <vi*****@visualtrans.de> wrote in message news:<cd**********@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
Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by ted | last post: by
1 post views Thread by wolf | last post: by
7 posts views Thread by Daniel Bickett | last post: by
6 posts views Thread by Anthony L. | last post: by
1 post views Thread by treelife | last post: by
2 posts views Thread by exhuma.twn | last post: by
3 posts views Thread by Michael | last post: by
4 posts views Thread by Con | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.