Here is the most minimal request handler possible:
1 def handler(req):
2 return 0
The server will respond with something like this (depending on its configuration):
HTTP/1.x 200 OK Date: Sat, 02 Dec 2006 17:29:23 GMT Server: Apache/2.2.3 (Unix) mod_ssl/2.2.3 OpenSSL/0.9.7g Pragma: no-cache Cache-Control: no-cache Expires: -1 Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html;charset=utf-8
A request handler must contain a handler() function that takes the request object as an argument:
1 def handler(req):
It must then return a status code, in the form of an integer:
1 return 0
In our example, we used zero (0). In subsequent examples, you may see the value of apache.OK returned. This constant, mod_python.apache.OK, is simply defined as zero (0).
This example assumes an understanding of how to define a request handler for a directory or location, a topic which will be discussed elsewhere.