@cached
    @gen.coroutine
    def get(self, path):

        localfile_path = os.path.abspath(
            self.settings.get('localfile_path', ''))

        abspath = os.path.abspath(os.path.join(
            localfile_path,
            path
        ))

        app_log.info("looking for file: '%s'" % abspath)

        if not abspath.startswith(localfile_path):
            app_log.warn("directory traversal attempt: '%s'" % localfile_path)
            raise web.HTTPError(404)

        if not os.path.exists(abspath):
            raise web.HTTPError(404)

        with io.open(abspath, encoding='utf-8') as f:
            nbdata = f.read()

        yield self.finish_notebook(nbdata, download_url=path,
                                   msg="file from localfile: %s" % path,
                                   public=False,
                                   format=self.format,
                                   request=self.request)
dataset/ETHPy150Open jupyter/nbviewer/nbviewer/providers/local/handlers.py/LocalFileHandler.get/original