Toadhttpd

Update of "Content"
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview

Artifact ID: 39daa85c0c65b294a23b22a75ae57b2e618ae02c0033f0d87a6f495e21b87abc
Page Name:Content
Date: 2018-05-03 23:06:14
Original User: hypnotoad
Parent: 0d197700d77375b676a5cb2b2ea70d1ba5ce921f0bf08c67c778f8ff50db5bc0
Content

Content

Producing content for toadhttpd can be accomplished in a few ways.

Template Files

If you are generating a simple system that just needs a few server side tweaks, toadhttpd supports the tclhttpd style template files.

Instead of naming a file .html, name it .tml. Before delivery, the file will be read into the server, and Tcl will use subst to substitute any command calls and perform variable substitutions. The result of that is sent as the final output.

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:

[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]

Simple Custom Reply Object

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.
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]
   }

}

Complex Custom Reply Object

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

tool::define myproject::reply.secure {
  method dispatch args {} {}
}