2
|
1 |
#!/usr/bin/env python2.5
|
|
2 |
|
|
3 |
DEBUG = True
|
|
4 |
|
|
5 |
# imports
|
|
6 |
if DEBUG :
|
|
7 |
import cgitb; cgitb.enable()
|
|
8 |
|
|
9 |
# system modules
|
|
10 |
import cgi, os
|
|
11 |
|
|
12 |
# my modules/packages
|
|
13 |
import request
|
5
|
14 |
import loaders
|
2
|
15 |
|
|
16 |
def dump_environ () :
|
|
17 |
print "<!--"
|
|
18 |
|
|
19 |
for k, v in os.environ.iteritems() :
|
|
20 |
print "%25s: %s" % (k, v)
|
|
21 |
|
|
22 |
print "-->"
|
|
23 |
|
|
24 |
# main
|
|
25 |
def main (environ) :
|
|
26 |
# load our req
|
|
27 |
req = request.Request(environ, default_page='main')
|
|
28 |
|
|
29 |
# get the page handler
|
5
|
30 |
page = loaders.load_page(req)
|
2
|
31 |
|
|
32 |
# render
|
|
33 |
print "Status: %d\r\n" % page.get_response_code(),
|
|
34 |
print "Content-Type: text/html\r\n",
|
|
35 |
print "\r\n",
|
|
36 |
print "%s\r\n" % page.render_template()
|
|
37 |
|
|
38 |
# debug output
|
|
39 |
if DEBUG :
|
|
40 |
dump_environ()
|
|
41 |
|
|
42 |
if __name__ == '__main__' :
|
|
43 |
main(os.environ)
|
|
44 |
|