changeset 17:d15f85eb2ab9

optionally display upload directory contents
author Jeff Hammel <jhammel@mozilla.com>
date Sat, 16 Jul 2011 10:48:33 -0700
parents 657e8df14187
children cc5f567ce840
files uploader/handlers.py
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/uploader/handlers.py	Sat Jul 16 10:38:46 2011 -0700
+++ b/uploader/handlers.py	Sat Jul 16 10:48:33 2011 -0700
@@ -37,7 +37,15 @@
         form = "<html><body>"
         if 'uploaded' in self.request.GET:
             form += '<div>%s uploaded successfully</div>' % self.request.GET['uploaded']
-        form += self.form + '</body></html>'
+        form += self.form
+        if self.app.display_contents:
+            contents = os.listdir(self.app.directory)
+            if contents:
+                contents.sort()
+                form += '<div><i>Currently uploaded:<ul><li>' + '</li><li>'.join(contents) + '</li></ul></i></div>'
+            else:
+                form += '<div><i>No files in upload directory</i></div>'
+        form += '</body></html>'
         return Response(content_type='text/html', body=form)
 
 class Post(Handler):