从外部 URL 打开文件#
警告
本指南中提到的第三方扩展默认不包含在 JupyterLite 中。可能还有其他 JupyterLab 扩展可以实现相同的行为,您可能需要考虑。本指南仅供参考和方便,以说明如何在您的 JupyterLite 站点中启用此类功能。
默认情况下,JupyterLite 不支持从外部 URL 打开文件。
但是,您可以安装 jupyterlab-open-url-parameter 扩展来启用此功能。
在您的构建环境中,安装该扩展
pip install jupyterlab-open-url-parameter
然后像往常一样构建您的 JupyterLite 站点
jupyter lite build
该扩展应该会在您的站点中自动启用。
该扩展将通过 URL 参数打开文件。URL 参数是 fromURL
。可以通过 fromURL
参数传递多个文件。文件将按照它们传递的顺序打开。
例如,如果您想打开一个 notebook 和一个 csv 文件
https://raw.githubusercontent.com/jupyterlab/jupyterlab-demo/master/notebooks/Lorenz.ipynb
https://raw.githubusercontent.com/jupyterlab/jupyterlab-demo/master/data/iris.csv
您可以将以下内容附加到您的 JupyterLab 实例的 URL:?fromURL=https://raw.githubusercontent.com/jupyterlab/jupyterlab-demo/master/notebooks/Lorenz.ipynb&fromURL=https://raw.githubusercontent.com/jupyterlab/jupyterlab-demo/master/data/iris.csv
这将导致以下 URL
http://your-jupyterlite.example.com/lab?fromURL=https://raw.githubusercontent.com/jupyterlab/jupyterlab-demo/master/data/iris.csv&fromURL=https://raw.githubusercontent.com/jupyterlab/jupyterlab-demo/master/notebooks/Lorenz.ipynb
注意
有关此扩展的更多信息,请查看 jupyterlab-open-url-parameter 存储库。
参考资料#
请查看添加扩展的指南,了解有关如何向 JupyterLite 站点添加扩展的更多信息。