[Ilugc] Python - Apache2 doubt

  • From: siva.devel@xxxxxxxxx (Sivaram Kannan)
  • Date: Wed Oct 8 09:57:33 2008

Hi all,

I have a doubt in accessing python through Apache. I have the
following configuration in my apache2/site-default/default file.

 <Directory /var/www/python>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
                AddHandler mod_python .py
                PythonHandler first
                PythonDebug on
</Directory>

My /var/www/first.py file looks like this.

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

def get_time():

        html = """
                <html><head>
                <title>get_time function</title>
                </head>
                <body>
                        <h1>get_time function</h1>
                        <hr>
                                The local time of this server is:  %s <br>
                                The timezone of this server is  :  %s <br>
                </body>
        </html>""" % (time.ctime(time.time()), time.timezone/3600)


When I give the following url "http://localhost/first.py" the function
handler is getting executed. But when I give the url
"http://localhost/first.py/get_time" the function get_time is not
getting called. What should I do to call anyfunction in a python
script through mod_python?

I am using Debian Lenny for this.

regards,
siva.

Other related posts: