#!/Library/Frameworks/Python.framework/Versions/Current/bin/python # L-37 MCS 275 Wed 14 Apr 2010 : show_hello_world1.py # This CGI script takes the input of the form show_hello_world1.html # and writes the code in plain text to the web page. import cgi form = cgi.FieldStorage() L = form['language'].value if L == '0': c = '#include \n\n' \ + 'int main(void)\n' \ + '{\n' \ + ' printf(\"Hello World!\\n\");\n' \ + ' return 0;\n' \ + '}\n' elif L == '1': c = 'public class HelloWorld\n' \ + '{\n' \ + ' public static void main(String[] args)\n' \ + ' {\n' \ + ' System.out.print(\"Hello World!\");\n' \ + ' System.out.println();\n' \ + ' }\n' \ + '}\n' else: c = 'print \"Hello World!\"' print "Content-Type: text/plain\n" print c