By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,824 Members | 1,252 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,824 IT Pros & Developers. It's quick & easy.

Embeded Python in Apache2 not doing its job

P: 6
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
Dec 8 '06 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.