On 4/27/19, Jungle Boogie <jungleboog...@gmail.com> wrote:
>
> Would you ever consider adding support to list an index of a directory?
> http://127.0.0.1/files would display whatever is in the /files directory.

Probably not.  That seems to violate the keep-it-simple principle of
althttpd.  On the rare occasions where a directory listing is actually
needed and desirable, such a listing is easily accomplished using CGI.
See https://wapp.tcl.tk/home/file/examples/filelist.tcl for example.
CGI also allows you to customize the styling and text surrounding the
listing.

A real-world example of this sort of thing can be seen at the
https://fossil-scm.org/skins/index.html page which is just a CGI
script that looks for other CGI scripts and provides links to them.
The complete text of the CGI script that generates that page is as
follows:

#!/usr/bin/wapptclsh
#
proc wapp-default {} {
  wapp-trim {
    <html>
    <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Fossil Skins</title>
    </head>
    <body>
    <h1>Fossil Self-Hosting With Built-In Skins</h1>
    <p>The following links run the Fossil self-hosting repository using
    the various built-in skins.  Use these for testing the built-in
    skins.</p>

    <p>The <a href='/fossil'>main self-hosting repository</a> uses a
    customized skin, different from all of the built-ins shown below.</p>

    <ol>
  }
  set parentdir [file dir [wapp-param SCRIPT_NAME]]
  foreach file [lsort [glob -nocomplain *]] {
    if {[regexp {[^a-z0-9_]} $file]} continue
    if {![file executable $file]} continue
    set url $parentdir/$file/timeline
    wapp-subst {<li><a href='%url($url)'>%html($file)</a>\n}
  }
  wapp-subst {</ol>\n}
}
wapp-start $argv

-- 
D. Richard Hipp
d...@sqlite.org
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to