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
+++ b/uploader/handlers.py
@@ -32,17 +32,25 @@ class Get(Handler):
         if app.query_string and (app.query_string not in request.GET):
             return False
         return request.method == 'GET'
 
     def __call__(self):
         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):
 
     @classmethod
     def match(cls, app, request):
         return request.method == 'POST'