Page 269 -
P. 269

web development




              The include_footer() function produces HTML that terminates a web page, providing links (if provided as a
              dictionary). An empty dictionary switches off the inclusion of the linking HTML:
              >>> include_footer({'Home': '/index.html', 'Select': '/cgi-bin/select.py'})
              '<p>\n<a href="/index.html">Home</a>    <a href="/cgi-bin/select.
              py">Select</a>    \n</p>\n</body>\n</html>\n'
              >>> include_footer({})
              '<p>\n\n</p>\n</body>\n</html>\n'          With links included, and
                                                         without.
              The start_form() and end_form() functions bookend a HTML form, with the parameter (if supplied)
              adjusting the contents of the generated HTML:
              >>> start_form("/cgi-bin/process-athlete.py")
                                                                          The argument allows you to specify
             '<form action="/cgi-bin/process-athlete.py" method="POST">'  the name of the program on the
              >>> end_form()                                              server to send the form’s data to.
             '<p></p><input type=submit value="Submit"></form>'
              >>> end_form("Click to Confirm Your Order")
             '<p></p><input type=submit value="Click to Confirm Your Order"></form>'
              HTML radio buttons are easy to create with the radio_button() function:
              >>> for fab in ['John', 'Paul', 'George', 'Ringo']:
                     radio_button(fab, fab)                                 Which one is your favorite?
                                                                            Select from the list of radio
             '<input type="radio" name="John" value="John"> John<br />'     buttons.
             '<input type="radio" name="Paul" value="Paul"> Paul<br />'
             '<input type="radio" name="George" value="George"> George<br />'
             '<input type="radio" name="Ringo" value="Ringo"> Ringo<br />'
              Unordered list are a breeze with the u_list() function:
                                                                         Again, not too easy on your eye, but
              u_list(['Life of Brian', 'Holy Grail'])                    fine as far as your web browser is
             '<ul><li>Life of Brian</li><li>Holy Grail</li></ul>'        concerned.
              The header() function lets you quickly format HTML headings at a selected level (with 2 as the default):
              >>> header("Welcome to my home on the web")
             '<h2>Welcome to my home on the web</h2>'                   Nothing too exciting here, but it works
              >>> header("This is a sub-sub-sub-sub heading", 5)        as expected. Same goes for here.
             '<h5>This is a sub-sub-sub-sub heading</h5>'


              Last, but not least, the para() function encloses a chunk of text within HTML paragraph tags:
              >>> para("Was it worth the wait? We hope it was...")
             '<p>Was it worth the wait? We hope it was...</p>'





                                                                                      you are here 4    233
   264   265   266   267   268   269   270   271   272   273   274