Q:

How do I serve up a directory list from web.py

I've written a little app in web.py and it works fine. It also delivers some images that are generated and dumped into a folder inside the static dir. 
I also want to be able to show the list of files and folders inside static. How do I enable listview?

A:

Typically you don't quite "enable" it. But there are a couple of choices you have.
1) Integrate it into your favorite webserver as a module. Here is how to run it as a FastCGI in lighttpd. There are also options for integrating with Apache.
see webpy.org for more info 
server.modules   += ( "mod_fastcgi" )
server.modules   += ( "mod_rewrite" )

fastcgi.server = ( "/code.py" =>
(( "socket" => "/tmp/fastcgi.socket",
  "bin-path" => "/path-to/webpy-app/code.py",
  "max-procs" => 1,
 "bin-environment" => (
   "REAL_SCRIPT_NAME" => ""
 ),
 "check-local" => "disable"
))
)

url.rewrite-once = (
 "^/favicon.ico$" => "/static/favicon.ico",
 "^/static/(.*)$" => "/static/$1",
 "^/(.*)$" => "/code.py/$1",
)

2) Or write code in your python app to handle it.
class list:
  def GET(self,irl):
    thisfile = inspect.getfile(inspect.currentframe())
    thispath = os.path.dirname(os.path.abspath(thisfile))
    dir = os.listdir("%s/static/%s"%(thispath,irl))
    rel = irl
    files = []
    folds = []
    for item in dir:
      if os.path.isfile("%s/static/%s/%s"%(thispath,irl,item)):
        files.append(item)
      elif item!='res':
        folds.append(item)
    return render.list(rel,folds,files)         

...and in the template...
$def with (rel,folds,files)
...
$if len(folds)>0:
  $for fold in folds:
    <a class='fold' href='/list$rel/$fold'>$fold</a>
...
$if len(files)>0:
  $for file in files:
    <a class='file' href='/$rel/$file'>$file</a>

