Posted to tcl by Colin at Tue Jul 22 14:15:05 GMT 2008view raw
- #! /usr/bin/env tclsh
- # Single Threaded Minimal File Server Site
- lappend auto_path [pwd] ;# path to the Site.tcl file
- namespace eval Site {
- variable varnish {}
- variable home [file dirname [info script]]
- }
- package require Site
- # This is a File domain which serves simple files
- # from the eponymous directory. Each file served has an expiry
- # date as indicated, which allows caching.
- File docroot -root $::Site::docroot
- #### Incoming - handle of incoming request
- #
- # This proc is called with a fully parsed incoming request.
- # It uses Responder to act like tcl's [switch] command,
- # but wraps errors in an appropriate HTML response.
- proc Incoming {req} {
- # [Responder Incoming] provides a safe wrapper and switch-like
- # dispatcher for incoming requests.
- return [Responder Incoming $req -glob -- [dict get $req -path] {
- / -
- /* {
- # redirect / to /wub
- docroot do $req
- }
- }]
- }
- # Start Site Server(s)
- Site start