Source

Yafi / pre-tests / cgi-bin / pyhello

Full commit
#!/usr/bin/python
import sys
try: 
    import cgitb
    cgitb.enable()
except ImportError:
    sys.stderr = sys.stdout
 
def cgiprint(inline=''):
    sys.stdout.write(inline)
    sys.stdout.write('\r\n')
    sys.stdout.flush()           
 
contentheader = 'Content-Type: text/html'
 
thepage = '''<html><head>
<title>%s</title>
</head><body>
%s
</body></html>
'''
h1 = '<h1>%s</h1>'
 
if __name__ == '__main__':
    cgiprint(contentheader)   # 
    cgiprint()                # 
 
    title = 'Hello World'
    headline = h1 % 'Hello, world!'
 
    print thepage % (title, headline)   #