question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support index files

See original GitHub issue

Eg: if there’s an foo/index.html it should be served at foo/. Also, foo should redirect to foo/.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:12 (10 by maintainers)

github_iconTop GitHub Comments

4reactions
evansdcommented, Jul 4, 2017

I’ve finally added built-in support for serving index files in the upcoming 4.0 release: http://whitenoise.evans.io/en/latest/django.html#index-files-django

4reactions
edmorleycommented, Nov 22, 2016

And for WhiteNoise 3+, something like:

from whitenoise.middleware import WhiteNoiseMiddleware


class IndexWhiteNoise(WhiteNoiseMiddleware):
    """Adds support for serving index pages for directory paths."""

    INDEX_NAME = 'index.html'

    def update_files_dictionary(self, *args):
        super(IndexWhiteNoise, self).update_files_dictionary(*args)
        index_page_suffix = '/' + self.INDEX_NAME
        index_name_length = len(self.INDEX_NAME)
        directory_indexes = {}
        for url, static_file in self.files.items():
            if url.endswith(index_page_suffix):
                # For each index file found, add a corresponding URL->content mapping
                # for the file's parent directory, so that the index page is served for
                # the bare directory URL ending in '/'.
                parent_directory_url = url[:-index_name_length]
                directory_indexes[parent_directory_url] = static_file
        self.files.update(directory_indexes)

    def find_file(self, url):
        # In debug mode, find_file() is used to serve files directly from the filesystem
        # instead of using the list in `self.files`, so we append the index filename so
        # that will be served if present.
        if url.endswith('/'):
            url += self.INDEX_NAME
        return super(IndexWhiteNoise, self).find_file(url)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Support index.js is not evaluated before cypress run command
Current behavior:​​ Per the documentation, the support file "runs before every single spec file". However, that is not the case for my scenario....
Read more >
Writing and Organizing Tests - Cypress Documentation
What you'll learn How to organize your test and support files. What languages are supported in your test files. How Cypress handles unit...
Read more >
Search indexing in Windows 10: FAQ - Microsoft Support
Indexing is the process of looking at files, email messages, and other content on your PC and cataloging their information, such as the...
Read more >
Cypress Index Support File. Write Once & Run Everywhere
Cypress Index Support File — Write Once & Run Everywhere. Have something you want to run before every test? Instead of adding it...
Read more >
Rebuild the Spotlight index on your Mac - Apple Support
Click Siri & Spotlight in the sidebar, then scroll down and click Spotlight Privacy on the right. Drag the disk or folder that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found