Why does the mptest.py source get shown instead of executed?

Apache/2.2.11 (Win32) mod_python/3.3.1 Python/2.5.2

The URL I tried using was: http://localhost/test/mptest.py

httpd.conf directives:
----------------------------------------
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"

<Directory /test>
  AddHandler mod_python .py
  PythonHandler mptest
  PythonDebug On
</Directory>
----------------------------------------

Under .../htdocs, I have "test" as a directory, containing this file:

----------------------------------------
from mod_python import apache

def handler( req ) :
  req.content_type = 'text/plain'
  req.write( "Hello World!" )
  return apache.OK
----------------------------------------

I followed the installation instructions found here:

http://www.modpython.org/live/current/doc-html/installation.html

and testing instructions found here:

http://www.modpython.org/live/current/doc-html/inst-testing.html

and the troubleshooting instructions found here:

http://www.modpython.org/live/current/doc-html/inst-trouble.html

As part of the troubleshooting, I added this directive to my httpd.conf:

----------------------------------------
<Location /mpinfo>
  SetHandler mod_python
  PythonHandler mod_python.testhandler
</Location>
----------------------------------------

I was able to access that page using:  http://localhost/mpinfo
and it showed the page in all its glory.

What am I missing?
LVL 41
HonorGodSoftware EngineerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HonorGodSoftware EngineerAuthor Commented:
Apparently, the issue was related to the fact that I had one "Directory" directive of the form:

<Directory />
  Options FollowSymLinks
  AllowOverride None
  Order deny,allow
  Deny from all
</Directory>

So, all I had to do was change the recommended Directory directive (above) to a location directory:

<Location /test>
  AddHandler mod_python .py
  PythonHandler mptest
  PythonPath "sys.path + ['C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/test']"
  PythonDebug On
</Location>

After recycling Apache (to refresh the modified configuration), I was able to successfully access:

http://localhost/test/mptest.py

and see:

Hello World!

instead of:


from mod_python import apache
 
def handler( req ) :
  req.content_type = 'text/plain'
  req.write( "Hello World!" )
  return apache.OK

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.