Install mod_python

N

Nancy

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
 
V

vincent wehren

Nancy said:
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
 
V

vincent wehren

Nancy said:
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
 
N

Nancy

vincent wehren said:
Nancy said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top