mod_python

Voraussetzungen: Apache Webserver mit mod_python

example1.psp

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> 

example2.py

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> 

example3.py

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 

Links

 
wissen/gpl/apache/mod_python.txt · Zuletzt geändert: 05.09.2010 20:31
 
Recent changes RSS feed Donate Valid XHTML 1.0 Valid CSS Recent cached RSS feed cacert-signed web site: inhalt.serviert.de