
import datetime, random

filename = "refreshingPage.html"
print datetime.datetime.now()
newTime = datetime.datetime.now()
oldTime = newTime

page = """
<html>
\t<head>
\t\t<meta http-equiv="refresh" content="5">
\t</head>
\t<body>
\t\tCurrent Time: {}<br>
\t\tTime from last refresh: {}
\t</body>
</html>"""

for x in xrange(10):
    fo = open(filename, 'w')
    newTime = datetime.datetime.now()
    randSleep = random.randint(1, 15)
    fo.write(page.format(newTime, (newTime - oldTime).seconds))
    fo.close()
    time.sleep(randSleep)
    oldTime = newTime
    print x, randSleep
