#
# jQuery File Tree
# Python/Django connector script
# By Martin Skou
#
import os
import urllib
def dirlist(request):
r=['
']
try:
r=['']
d=urllib.unquote(request.POST.get('dir','c:\\temp'))
for f in os.listdir(d):
ff=os.path.join(d,f)
if os.path.isdir(ff):
r.append('- %s
' % (ff,f))
else:
e=os.path.splitext(f)[1][1:] # get .ext and remove dot
r.append('- %s
' % (e,ff,f))
r.append('
')
except Exception,e:
r.append('Could not load directory: %s' % str(e))
r.append('
')
return HttpResponse(''.join(r))