Skip to content

Instantly share code, notes, and snippets.

@evansd
Last active August 29, 2015 14:23
Show Gist options
  • Select an option

  • Save evansd/4a696b94d4056e8a11e1 to your computer and use it in GitHub Desktop.

Select an option

Save evansd/4a696b94d4056e8a11e1 to your computer and use it in GitHub Desktop.
from whitenoise import WhiteNoise
class WhiteNoiseIndex(WhiteNoise):
index_file = 'index.html'
def add_files(self, *args, **kwargs):
super(WhiteNoiseIndex, self).add_files(*args, **kwargs)
index_urls = [url for url in self.files.keys() if url.endswith('/' + self.index_file)]
for url in index_urls:
new_url = url[:-len(self.index_file)]
self.files[new_url] = self.files[url]
def find_file(self, url):
if url.endswith('/'):
url = url + self.index_file
return super(WhiteNoiseIndex, self).find_file(url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment