CGI Web Python Tutorial

import cgi
form = cgi.FieldStorage()
if not form:
    print "Content-Type: text/html\n\n"
    print """
    
    
    
    
    """
elif form.has_key("filename"):
    uploadedfile = form["filename"]
    if uploadedfile.file:
        print "Content-Type: text/html\n\n"
        linecounter = 0
        while 1:
            line = uploadedfile.file.readline()
            print line
            if not line:
                break
            linecounter = linecounter + 1