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