<h1>Content</h1>
Producing content for toadhttpd can be accomplished in a few ways.
<h3>Template Files</h3>
If you are generating a simple system that just needs a few server side tweaks, toadhttpd supports the tclhttpd style template files.
<p>
Instead of naming a file .html, name it .tml. Before delivery, the file will be read into the server, and Tcl will use <b>subst</b> to substitute any command calls and perform variable substitutions. The result of that is sent as the final output.
<p>
Unlike tclhttpd (which executes the script in the virtual host interpreter), toadhttpd executes the command with the object that was created to handle the request. So your template can invoke that object's methods:
<p>
<verbatim>
[my html_header {Hello World!}]
Your Server is running.
<p>
The page your asked for was [my http_info get REQUEST_URI]. Despite appearences, that file is actually on the server as $local_file
<p>
The time is now [clock format [clock seconds]].
<p>
Have a nice day.
[my html_footer]
</verbatim>
<p>
<h3>Simple Custom Reply Object</h3>
For more complex projects, you can create a class to manage requests, and tell the server to invoke an object of that class when replying.

<verbatim>
tool::define myproject::reply.time {
   method content {} {
     set hour [clock format [clock seconds] -format %H]
     if {$hour > 20 || $hour < 5} {
       my content_nightowl
     } elseif {$hour >=5 && $hour < 12} {
       my content_morning
     } elseif {$hour >=12 && $hour < 5} {
       my content_afternoon
     } else {
       my content_evening
     }
   }

   method content_nightowl {} {
     my puts [my html_headers {Good god it's late}]
     # Content tailored for late, late night
     my puts [my html_footer]
   }
   method content_morning {} {
     my puts [my html_headers {Good morning!}]
     # Content tailored for in the morning
     my puts [my html_footer]
   }
   method content_afternoon {} {
     my puts [my html_headers {Good afternoon!}]
     # Content tailored for the afternoon
     my puts [my html_footer]
   }
   method content_evening {} {
     my puts [my html_headers {Good evening!}]
     # Content tailored for the evening
     my puts [my html_footer]
   }

}
</verbatim>

<h3>Complex Custom Reply Object</h3>
For some content, you need to control how the page is dispatched. Fortuntely, that isn't too hard to do either. You just override a different method.

Coming Soon
<verbatim>
tool::define myproject::reply.secure {
  method dispatch args {} {}
}
</verbatim>