473,396 Members | 1,809 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Can't run python code in Apache

6
Hello!

I posted below question in the "Python" forum and realized that maybe it should be in Apache forum instead ?

Anyways, I appreciate any help...

Thanks!
/P

---------------
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 10 '06 #1
3 6630
sashi
1,754 Expert 1GB
Hello!

I posted below question in the "Python" forum and realized that maybe it should be in Apache forum instead ?

Anyways, I appreciate any help...

Thanks!
/P

---------------
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
Hi there,

Kindly refer to below attached link for further reading & understanding, hope it helps. Good luck & Take care.

Python and Apache2 (mod_python) configuration - step by step guide
Dec 11 '06 #2
poppor
6
Hi there,

Kindly refer to below attached link for further reading & understanding, hope it helps. Good luck & Take care.

Python and Apache2 (mod_python) configuration - step by step guide

Thanks alot Sashi! Now I got it working!
Regards
/P
Dec 11 '06 #3
sashi
1,754 Expert 1GB
Thanks alot Sashi! Now I got it working!
Regards
/P
Hi there,

Good luck to you. Take care.
Dec 12 '06 #4

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

Similar topics

40
by: Shufen | last post by:
Hi all, Can someone who has use PHP before and know quite well about the language, tell me what are the stuffs that Python offers and PHP doesn't. A few examples will be nice. I know about the...
1
by: neha | last post by:
hi, i m trying to integrate python with apache on linux.For this i m using mod_python. I dont see any problem with the versions of python,apache and mod_python i m using. the versions i m using...
3
by: jbrewer | last post by:
I'm currently writing my first CGI script (in Python), and I keep getting an error I don't know how to address. I'm not sure if this is a Python or Apache error, but I suspect it's an Apache...
122
by: seberino | last post by:
I'm interested in knowing which Python web framework is most like Ruby on Rails. I've heard of Subway and Django. Are there other Rails clones in Python land I don't know about? Which one...
9
by: Matt Helm | last post by:
I am starting the design phase of a large project (ERP) where the backend will mostly be Python (or Ruby) providing web services. In this type of usage, is there any benenfit to running under...
113
by: John Nagle | last post by:
The major complaint I have about Python is that the packages which connect it to other software components all seem to have serious problems. As long as you don't need to talk to anything outside...
3
by: joe jacob | last post by:
I configured apache to execute python scripts using mod_python handler. I followed below mentioned steps to configure apache. 1. In http.conf I added <Directory...
13
by: oruccim | last post by:
hii my friends; I want to create picture of security code.can i do it ? if yes,how , which module will help me? have you got a example that can create a picture whit my name pls help me thansk...
1
by: Gowri | last post by:
Hello, I am new to Python and am trying to setup Apache to serve Python using mod_python. I'm using a Windows XP box. here is a list of steps i followed for the installation: 1. Installed...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.