Welcome to MobyThreads.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in
All support for the MobyThreads Threaded phpBB MOD can now be found on welsolutions at this forum

Python in Apache !?

 
   Web Hosting and Web Master Forums (Home) -> Apache RSS
Next:  rewrite_mod  
Author Message
spam44

External


Since: Jan 20, 2004
Posts: 5



(Msg. 1) Posted: Wed Jan 21, 2004 2:46 pm
Post subject: Python in Apache !?
Archived from groups: alt>apache>configuration (more info?)

Hi,

I have a little python-file, which I would like to run under my Apache. The
mod_python is installed. The script is the following:

#!/usr/bin/python
############################################################################
########
#news.py
# Kleine Funktion um aus der News.xml einen zufälligen aktiven Eintrag
auszuwählen.
############################################################################
########
import sys
import xml.dom.minidom
from xml.xpath import Evaluate
from random import Random


def getNews(datei):
path0 = "Eintrag[@aktiv=1]" # xpath auf den aktiven eintrag
i = 0 #zähler
Liste = [] #liste für die inhalte
dom = xml.dom.minidom.parse(datei) # datei öffnen

elements = Evaluate(path0, dom.documentElement) # liste der nodes
erzeugen


for element in elements:
if element:

Liste.append(element.firstChild.nodeValue.encode('utf-8'))#einträge in liste
schreiben
i= i + 1
#zufällig einen eintrah auswählen
rand = Random(None)
return Liste[rand.randint(0,(i-1))]

######################aufruf der funktion###########################
print getNews('news.xml')
####################################################################


If I call the script with
http://butschekconsult.dyndns.org/mpva/cgi-bin/news.py the only thing I see
is the script. What do I have to do, that my server will understand python.
Alternativly I could put the script into a pih- or a hip-file.

Do you have an hint for me?

Holger

 >> Stay informed about: Python in Apache !? 
Back to top
Login to vote
davideyeahsure

External


Since: Nov 03, 2003
Posts: 2907



(Msg. 2) Posted: Wed Jan 21, 2004 2:46 pm
Post subject: Re: Python in Apache !? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Holger Butschek <spam.DeleteThis@butschek-consult.de> wrote:
 > <a style='text-decoration: underline;' href="http://butschekconsult.dyndns.org/mpva/cgi-bin/news.py" target="_blank">http://butschekconsult.dyndns.org/mpva/cgi-bin/news.py</a> the only thing

Does your Apache knows that he must execute files in cgi-bin? Is that
your 'default' cgi-bin directory or you created it yourself?

Davide

--
| AFAIR, being insane is usually a pre-requisite for becoming a
| sysadmin. In the few cases where it's not pre-requisite, it's
| certainly going to be a bonus. --SIggi the Underpaid<!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: Python in Apache !? 
Back to top
Login to vote
spam44

External


Since: Jan 20, 2004
Posts: 5



(Msg. 3) Posted: Wed Jan 21, 2004 5:01 pm
Post subject: Re: Python in Apache !? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

 > Does your Apache knows that he must execute files in cgi-bin? Is that
 > your 'default' cgi-bin directory or you created it yourself?

No it is not the default cgi-bin. I temporarily added two entries in the
httpd.conf:

AddHandler cgi-script .cgi .pl .py

and

#<Directory "/srv/www/htdocs/mpva/cgi-bin">
# AllowOverride None
# Options +ExecCGI
# Order allow,deny
# Allow from all
#</Directory>

Then, I received an error message. access denied<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: Python in Apache !? 
Back to top
Login to vote
davideyeahsure

External


Since: Nov 03, 2003
Posts: 2907



(Msg. 4) Posted: Wed Jan 21, 2004 5:07 pm
Post subject: Re: Python in Apache !? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Holger Butschek <spam RemoveThis @butschek-consult.de> wrote:
 > #<Directory "/srv/www/htdocs/mpva/cgi-bin">
 > # AllowOverride None
 > # Options +ExecCGI
 > # Order allow,deny
 > # Allow from all
 > #</Directory>

If you don't remove the '#' from the beginning of the lines
they are comments.

Davide

--
| The Microsoft Motto: "We're the leaders, wait for us!"
|
|
|
|
|<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: Python in Apache !? 
Back to top
Login to vote
spam44

External


Since: Jan 20, 2004
Posts: 5



(Msg. 5) Posted: Wed Jan 21, 2004 6:40 pm
Post subject: Re: Python in Apache !? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

 > If you don't remove the '#' from the beginning of the lines
 > they are comments.


I know that. I wasn't sure if the entries were correct. Do I have to restart
the server after the changes.

Holger<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: Python in Apache !? 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Where is Apache 2 - Hi folks, I am quite new in the linux section. I have installed the Apache 2 packages. If I call my server with http then the following line is printed: Apache/2.0.48 (Linux/SuSE) If I use $ rpm -q apache something like apache-1.3. is printed. It seem...

php apache - Hi all my first group post hope it helps someone Although i agree with firepages as an easy way to sort php apache pluggin.. you get also quite a lot of othe things thrown in,, plus it's always good to know yourself how things work.... to cofigure php....

apache and ftp - i was looking an example of how to setup ftp under apache 2.0.48 and windows XP? Ciao pirates

apache 2.0.48 + ssl - hi @ all, i want do use the latest apache 2.0.48 with ssl (i use the latest openssl version 0.9.7c) i configured with: ../configure --prefix=/usr/local/apache2/2.0.48 --enable-ssl --with-ssl=/usr/ local/openssl/0.9.7c --enable-so make an make install o...

New to Apache - Hey everybody, I'm very new to Apache. My questions is: 1) What skills are necessary to use Apache 2.0 as a webserver? 2) Is Red Hat's native installation of Apache a good place to start?
   Web Hosting and Web Master Forums (Home) -> Apache All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]