Mercurial > hg > SimpleWiki
diff simplewiki/handlers.py @ 4:dd1c4916cbcd
[mq]: fileserver
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Tue, 07 Sep 2010 22:39:15 -0700 |
parents | 56ab6b90cd1a |
children | b2fbb4f982da |
line wrap: on
line diff
--- a/simplewiki/handlers.py Tue Sep 07 21:29:57 2010 -0700 +++ b/simplewiki/handlers.py Tue Sep 07 22:39:15 2010 -0700 @@ -4,6 +4,7 @@ """ import os +from paste.fileapp import FileApp from urlparse import urlparse from webob import Response, exc @@ -142,3 +143,16 @@ def __call__(self): self.redirect(self.location) + +class FileServer(Handler): + methods = set(['GET']) # methods to listen to + + def __init__(self, app, request): + Handler.__init__(self, app, request) + self.file = os.path.join(self.app.directory, *request.environ['path']) + if not os.path.exists(self.file): + raise HandlerMatchException + + def __call__(self): + return FileApp(self.file) +