Karrigell/Build a simple HTML page

There are 3 ways you can build HTML in a script

 

Raw HTML
The first one is to return a string with HTML tags, like this :



Templates
For a document that holds mainly static HTML, with only a few dynamic values, you can use templates. For instance, create a file called page.tmpl with:

and save it in the same folder as index.py. Then modify index.py like this:

The built-in function Template is available in all the scripts managed by Karrigell. It reads the content from the file located at the relative url page.tmpl and returns it. More on the templating system later.



The HTMLTags module
The third way, recommended when the page is mostly made of dynamic content, is to use the HTMLTags module, included in the package :

The HTMLTags module defines classes for all valid HTML tags, in uppercase letters : the classes for tags &lt;html&gt; and &lt;body&gt; are  and   (surprise !). These classes are available in the scripts managed by Karrigell

The function index returns an instance of the class, called with an instance of the class   ; the server returns its string representation, which is the HTML code 