Super-mini web server that I use as a demonstration for presentations. Not correct or complete, but it does serve files... It can also reload its own code if you hit it at the /reload url! ---- proc Serve {chan addr port} { fconfigure $chan -translation auto -buffering line set line [gets $chan] set path [file join . [string trimleft [lindex $line 1] /]] if { $path == "." } {set path ./index.html} if { $path == "./reload" } { set reload 1 source [info script] puts $chan "HTTP/1.0 200 OK" puts $chan "Content-Type: text/html" puts $chan "" puts $chan "Server reloaded" } else { #puts "Request: $path" ;## if { [catch { set fl [open $path] } err] } { puts $chan "HTTP/1.0 404 Not Found" } else { puts $chan "HTTP/1.0 200 OK" puts $chan "Content-Type: text/html" puts $chan "" puts $chan [read $fl] close $fl } } close $chan } #catch {console show} ;## if { ! [info exists reload] } { set sk [socket -server Serve 5151] vwait forever } else { unset reload } ---- Point your browser to '''http://localhost:5151''' [HJG] Added "index.html" as default-url. ---- ''See also:'' * [DustMote] * [Inspecting app state with a browser] * [Embedded TCL Web Server] - with SSL and Basic Auth ---- [Category Application] | [Category Internet]