Wapp Script That Generates https://wapp.tcl.tk/demo/index.html

#!/usr/bin/wapptclsh
package require wapp
proc common-header {} {
  wapp-trim {
    <html>
    <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <link href="%url([wapp-param SCRIPT_NAME]/style.css)" rel="stylesheet">
    <body>
  }
}
proc common-footer {} {
  wapp-trim {
    </body>
    </html>
  }
}
proc wapp-default {} {
  set self [wapp-param SCRIPT_FILENAME {}]
  cd [file dir $self]
  set selftail [file tail $self]
  regsub {/[^/]+$} [wapp-param BASE_URL] {} base
  common-header
  wapp-trim {
     <h1>Available Demos:</h1>
     <ol>
  }
  foreach file [lsort [glob -nocomplain *]] {
    if {[file isdir $file]} continue
    if {![file readable $file]} continue
    if {$file==$selftail} {
      wapp-trim {
         <li><a href="%html($base/$file)/self">(This script)</a></li>
      }
    } else {
      wapp-trim {
         <li><a href="%html($base/$file)">%html($file)</a></li>
      }
    }
  }
  wapp-trim {
    </ol>
  }
  common-footer
}

# The /self page that shows the text of this script.
#
proc wapp-page-self {} {
  wapp-cache-control max-age=3600
  common-header
  set base [wapp-param BASE_URL]
  set fd [open [wapp-param SCRIPT_FILENAME] rb]
  set script [read $fd]
  close $fd
  wapp-trim {
    <h1>Wapp Script That Generates <a href="%html($base)">%html($base)</a></h1>
    <pre>%html($script)</pre>
  }
  common-footer
}
proc wapp-page-style.css {} {
  wapp-mimetype text/css
  wapp-cache-control max-age=3600
  wapp-trim {
    pre {
       border: 1px solid black;
       padding: 1ex;
    }
  }
}

wapp-start $argv