Voraussetzungen: Apache Webserver mit mod_python
Python eingebunden als python Server Page.
<html>
<head>
<title>Welcome</title>
</head>
<body>
<%
title = "<H1>Welcome to the world of Python</H1>"
greeting = "If you lived here, you'd be home by now"
res.write(title)
res.write("<P>")
res.write(greeting)
%>
</body>
</html>
mod_python Ansatz
from mod_python import apache def handler(req): title = "<H1>Welcome to the world of mod_python</H1><P>" greeting = "If you lived here, etc." req.content_type = "text/html" req.send_http_header() req.write(title) req.write(greeting) return apache.OK
httpd.conf
<Directory /python> AddHandler python-program .py PythonHandler welcome </Directory>
httpd.conf - publisher aktivieren
AddHandler python-program .py PythonHandler mod_python.publisher
welcome.py
def say_goodbye(): s = "<H1>Thanks for visiting!</H1>" return s def say_hello(): h1open = "<H1>" h1close = "</H1>" s = h1open + "Welcome to mod_python publisher." + h1close return s