- Notifications
You must be signed in to change notification settings - Fork5.5k
Fix opening files from the CLI#6946
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
jtpio commentedJun 23, 2023
So the idea if that we should be able to open files from the CLI by using the existing |
jtpio commentedJun 23, 2023
cc@parmentelat if you want to try with the built artifacts:https://github.com/jupyter/notebook/actions/runs/5356963835?pr=6946 |
jtpio commentedJun 26, 2023
For reference
|
| extension_url="/" | ||
| default_url=Unicode("/tree",config=True,help="The default URL to redirect to from `/`") | ||
| file_url_prefix="/notebooks" | ||
| file_url_prefix="/tree" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
So the idea of using/tree is that there is already a redirect handler to open either with/edit or/notebooks:
Lines 127 to 160 in7f1a2f4
| asyncdefget(self,path=None): | |
| """ | |
| Display appropriate page for given path. | |
| - A directory listing is shown if path is a directory | |
| - Redirected to notebook page if path is a notebook | |
| - Render the raw file if path is any other file | |
| """ | |
| path=path.strip("/") | |
| cm=self.contents_manager | |
| ifawaitensure_async(cm.dir_exists(path=path)): | |
| ifawaitensure_async(cm.is_hidden(path))andnotcm.allow_hidden: | |
| self.log.info("Refusing to serve hidden directory, via 404 Error") | |
| raiseweb.HTTPError(404) | |
| # Set treePath for routing to the directory | |
| page_config=self.get_page_config() | |
| page_config["treePath"]=path | |
| tpl=self.render_template("tree.html",page_config=page_config) | |
| returnself.write(tpl) | |
| elifawaitensure_async(cm.file_exists(path)): | |
| # it's not a directory, we have redirecting to do | |
| model=awaitensure_async(cm.get(path,content=False)) | |
| ifmodel["type"]=="notebook": | |
| url=ujoin(self.base_url,"notebooks",url_escape(path)) | |
| else: | |
| # Return raw content if file is not a notebook | |
| url=ujoin(self.base_url,"files",url_escape(path)) | |
| self.log.debug("Redirecting %s to %s",self.request.path,url) | |
| self.redirect(url) | |
| else: | |
| raiseweb.HTTPError(404) |
Investigate ways tofix#6914