langhtml ""% % ""def showhello(form)html for one language choice form[inputkeyvalue escape lang name too tryprint(langhtml (cgi escape(choice)cgi escape(hellos[choice]))except keyerrorprint(langhtml (cgi escape(choice)"sorry-- don' know that language")def main()if debugmeform {inputkeyfieldmockup(sys argv[ ])elseform cgi fieldstorage(name on cmd line parse real inputs print(hdrhtmlif not inputkey in form or form[inputkeyvalue ='all'for lang in hellos keys()mock {inputkeyfieldmockup(lang)not dict( =vhereshowhello(mockelseshowhello(formprint(''if __name__ ='__main__'main(when global debugme is set to truethe script can be tested offline from simple command line as beforec:\pp \internet\web\cgi-binpython languages reply py python content-typetext/html languages syntax python print('hello world'when run online using either the page in figure - or an explicitly typed url with query parameterswe get the same reply pages we saw for the original version of this example (we won' repeat them here againthis transformation changed the program' architecturenot its user interface architecturallythoughboth the input and reply pages are now created by python cgi scriptsnot static html files server-side scripting