In the previous step, you generated CGI header lines and a single plain text "content" line. In this step, you will expand the content portion and embed HTML tags within it. As a result, when the data are displayed by a Web browser, they will be formatted as conventional HTML data.You may wish to begin with your
Hello, World, from CGIscript and edit it. If you do, you should change thecontent-typefromtext/plaintotext/htmlsince your program will be generating HTML.There's really nothing to generating the HTML data. You "write" it just like you normally do for a conventional, static document, except that each line is placed inside a
\n) character, if that is desired.Following is a
Hello, World, in HTMLprogram, set up like one of the standard pages used for course materials.Hello, World, in HTML program
#!/usr/local/bin/perl print "200 ok\n"; print "content-type: text/html\n\n"; print "<HTML>\n"; print "<HEAD>\n"; print "<TITLE>hello, world html </TITLE>\n"; print "<H2>Hello, World, in HTML </H2>\n"; print "</HEAD>\n"; print "<BODY>\n"; print "<HR>\n"; print "Hello, World, in HTML\n"; print "</BODY>\n";Write your own
Hello, World, in HTMLprogram, test it, and put it in yourcgi-bindirectory. If you like, you can execute the program, above: Hello, World, in HTML.