Embeded Python in Apache2 not doing its job

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • poppor
    New Member
    • Dec 2006
    • 6

    #1

    Embeded Python in Apache2 not doing its job

    Hi,

    I'm new to both Python and Apache so sorry for any upcoming
    dummy questions :)

    I'm running Linux (Ubuntu 6.10) and have installed the following:
    - Apache 2.0.55
    - Python 2.4.4c1
    - libapache2-mod-python

    One thing I'm still not clear about is if mod-python and CGI scripts are
    the same thing or not ? Because I think I've got it all mixed up. I don't
    think that mod-python is really needed to run python scripts or am I
    wrong ?

    Anyways, in /etc/apache2/apache2.conf I have the following lines
    AddHandler cgi-script .py
    <Directory /var/www>
    AddHandler mod_python .py
    </Directory>

    In the directory /var/www I have 2 files htmlgen.py and mypage.html

    File: htmlgen.py
    ------------------------
    import cgi

    print "Content-type: text/html\n\n"
    print "Testing... "

    File mypage.html
    --------------------------
    <form action="htmlgen .py" method="post">
    <input type="submit" value="Test">
    </form>

    Now when I open mypage.html I get a button saying "Test". When I press this button Firefox wants to download the file called htmlgen.py. Why? Apache is not running the file, just sending it.

    I hope someone can help me. I've read all documentation I could find but don't know what is wrong.

    Best Regards
    /P
Working...