usr bin python coding utf-8 import cgi cgitb import sys from jinja2 im

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/python
# -*- coding: utf-8 -*-
import cgi, cgitb
import sys
from jinja2 import Template
from jinja2 import Environment, FileSystemLoader
print "Content-type:text/html\n"
cgitb.enable()
env = Environment(loader=FileSystemLoader('/www/site/templates/',encoding='utf-8'))
templ = env.get_template("index.html")
str = templ.render()
def ucgiprint(inline='', unbuff=False, encoding='UTF-8'):
"""Print to the stdout.
Includes keywords to define the output encoding
(UTF-8 default, set to None to switch off encoding)
and also whether we should flush the output buffer
after every write (default not).
"""
line_end = '\r\n'
if encoding:
inline = inline.encode(encoding)
# prob. not necessary as line endings will be the
# same in most encodings
line_end = line_end.encode(encoding)
sys.stdout.write(inline)
sys.stdout.write(line_end)
if unbuff:
sys.stdout.flush()
ucgiprint(str)