404 on attempt to list notebooks in nonexistant directory

This commit is contained in:
Thomas Kluyver 2013-10-08 16:12:45 -07:00 committed by MinRK
parent 18f88d020f
commit b1a0f2e8cc

View File

@ -76,6 +76,8 @@ class FileNotebookManager(NotebookManager):
def get_notebook_names(self, path=''):
"""List all notebook names in the notebook dir and path."""
path = path.strip('/')
if not os.path.isdir(self.get_os_path(path=path)):
raise web.HTTPError(404, 'Directory not found: ' + path)
names = glob.glob(self.get_os_path('*'+self.filename_ext, path))
names = [os.path.basename(name)
for name in names]