# encoding: utf-8 import simplejson as json from glob import glob from os.path import dirname as d, join, basename, getctime BASE = d(d(__file__)) def index(req, **kw): req.content_type = "application/json" paths = glob(join(BASE, '*.mp3'))# + glob(join(BASE, '*.m4a')) files = [ basename(f) for t,f in sorted( (getctime(f), f) for f in paths )] req.write( json.dumps(files) )