print('content-typetext/html\ 'print('% % page (pp )(appkind)print('% % (colorapp(info or kind))def pagefooter(root='pymailcgi html')print('< href="print('<img src=/pythonpoweredsmall gif'print('align=left alt="[python logo]border= hspace= >'print('back to root pagerootprint(''def formatlink(cgiurlparmdict)""make "%url?key=val&key=valquery link from dictionaryescapes str(of all key and val with %xxchanges to note that url escapes are different from html (cgi escape""parmtext urllib parse urlencode(parmdictcalls parse quote_plus return '% ?% (cgiurlparmtexturllib does all the work def pagelistsimple(linklist)show simple ordered list print(''for (textcgiurlparmdictin linklistlink formatlink(cgiurlparmdicttext cgi escape(textprint('\ % (linktext)print(''def pagelisttable(linklist)show list in table print(''escape text to be safe for (textcgiurlparmdictin linklistlink formatlink(cgiurlparmdicttext cgi escape(textprint('view\ % (linktext)print(''def listpage(linkslistkind='selection list')pageheader(kind=kindpagelisttable(linkslist[('text''cgiurl'{'parm':'value'})pagefooter(def messagearea(headerstextextra='')extra for readonly addrhdrs ('from''to''cc''bcc'decode names only print(''for hdr in ('from''to''cc''subject')rawhdr headers get(hdr'?'if hdr not in addrhdrsdechdr parser decodeheader(rawhdr decode for display elseencoded on sends dechdr parser decodeaddrheader(rawhdremail names only val cgi escape(dechdrquote= print('% :hdrprint(<input type=text 'print(name=% value="% % size= >(hdrvalextra) the pymailcgi server