#!/usr/bin/python
# -*- coding: utf-8 -*-

import sys
import time
import cgi

# Following line causes error to be sent to browser
# rather than to log file (great for debug!)

sys.stderr = sys.stdout

print "Content-type: text/html\n"

print """
<html>
<head><title>A page from Python</title></head>
<body>
<h4>This page is generated by a Python script!</h4>
The current date and time is """

now = time.gmtime()
displaytime = time.strftime("%A %d %B %Y, %X",now)

print displaytime,

form = cgi.FieldStorage()
aa = form.getfirst('user')
token = form.getfirst('token')

print "user", aa, "   token", token

if token:
	f = file('token', 'w')
	f.write(token)
	f.close()

print """
<hr>
Well House Consultants demonstration
</body>
</html>
"""

