TclHttpd: An Extensible Web Server for Embedding and Application Integration
TclHttpd is an embeddable and extensible web server designed to seamlessly integrate web interfaces into applications. It supports various functionalities, including licenses, DHCP, and mail list servers. With a focus on extensibility, it allows developers to implement complex HTML navigation and customizable URL handling through direct CGI procedures. Features include page templates, built-in form handlers, and the ability to manage document types and authentication hooks. TclHttpd serves as a general-purpose web server ideal for a wide range of applications.
TclHttpd: An Extensible Web Server for Embedding and Application Integration
E N D
Presentation Transcript
TclHttpdThe Tcl Web Server Brent Welch <welch@scriptics.com> www.scriptics.com/tclhttpd ftp.scriptics.com/pub/tcl/httpd Tcl/2k Conference, slide 1
Goals and Experiences • Embeddable, Extensible Web Server • Add web interface to your application • License server, DHCP server, Mail List Server • General Purpose Web Server • Page Templates • Built-in form handlers • sunscript.sun.com • www.scriptics.com Tcl/2k Conference, slide 2
Architecture for Extensibility File System Other Process Your Application Template App- Direct CGI Doc URL Dispatch HTTP Protocol Tcl/2k Conference, slide 3
URL Dispatch Implement a URL sub-tree, interpret meaning of URL path Application-Direct Maps a URL to a Tcl Procedure. Maps form data to procedure arguments. Document Templates Procedure calls, variable references inside HTML pages General Doc-Type handlers Authentication hook Architecture for Extensibility Tcl/2k Conference, slide 4
Url Dispatch: Partition Hierarchy /status /resource Url_PrefixInstall prefix command inThread Url_PrefixInstall /resource ResourceDispatch 0 Tcl/2k Conference, slide 5
Direct_Url /status Status proc Status/doc { {pattern *} {sort hits} } { # Display URLs matching $pattern # Sort display by name or hit count return $html } /status/doc?pattern=/images*&sort=name Missing parameters get default value, or “” Return value of proc is the page Set alternate content-types, not just text/html Application-DirectMap URL to Tcl Procedure Tcl/2k Conference, slide 6
Use Tcl to general complex HTML for navigation Put simple calls into pages [scriptics::header “Title” lev1 lev2 lev3] Cache template output in plain .html file Form handlers Embed calls to handle incoming form data “Self-posting forms” repopulate fields, then redirect to the next page when everything is OK Document Templates: HTML+Tcl Tcl/2k Conference, slide 7
32 K File Fetch Tcl/2k Conference, slide 8