#!/usr/bin/env python

import os, time

print "Content-type: text/html; charset=utf-8"
print """
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
    <head>
        <title>Test page</title>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    </head>

    <body>
"""

start = time.time()

def print_elapsed_time(step):
    global start
    elapsed_time = time.time() - start
    print '<p>' + str(elapsed_time) + 's : ' + step + '</p>'

print_elapsed_time('popen4 called')
inf, ouf = os.popen4('ls', 't')
print_elapsed_time('popen4 returned')

print_elapsed_time('string readlines start')
lines = ouf.readlines()
print_elapsed_time('string readlines end')

print_elapsed_time('printing starts')
print """
        <pre>
"""
for line in lines:
    print line,
print """
        </pre>
"""
print_elapsed_time('printing ends')

inf.close()
ouf.close()

print """
    </body>
</html>
"""
# vim: ts=4 sw=4 expandtab
