Skip to content

@aausch /StaticFileScanner.py
Last active

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Serves static files from multiple local directories at a single external url
# Serves static files from multiple local directories at a single external url
# usage demo: https://gist.github.com/aausch/7348230
#
# Copyright 2013, Alex Ausch
# Free to use under attribution license: http://creativecommons.org/licenses/by/2.0/ca/
from twisted.web.resource import Resource
from twisted.web.static import File
class StaticFileScanner(Resource):
dirs = []
def __init__(self, *dirs):
if (len(dirs) < 1):
self.dirs = [File()]
else:
self.dirs = [File(d) for d in dirs]
Resource.__init__(self)
def getChild(self, *args):
for d in self.dirs:
if d.getChild(*args) != d.childNotFound:
return d.getChild(*args)
return self.dirs[0].childNotFound
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.