Source code for: 'tutor3.py'


#!/usr/bin/python
"""
runs on the server, reads form input, prints HTML;
url=http://server-name/cgi-bin/tutor3.py
"""

import cgi

form = cgi.FieldStorage()            # parse form data
print('Content-type: text/html')     # plus blank line

html = """
<TITLE>tutor3.py</TITLE>
<body text="#000000" leftmargin=0 topmargin=0 bgcolor="#C2C2C6">
<table width=850 border=0 cellspacing=0 cellpadding=0>
  <tr>
  <td align=center>
<H1>Greetings</H1>
<HR>
<P>%s</P>
<HR>"""

if not 'user' in form:
    print(html % 'Who are you?')
else:
    print(html % ('Hello, %s.' % form['user'].value))

print("""
</table>
</td></tr></table>
""")