首页 > 解决方案 > nbviewer - 无法服务器本地文件

问题描述

我的问题与这个问题非常相似:我正在尝试在本地 nbviewer 服务器上提供本地文件。

/home/user/nbviewer/nbviewer/我在启动 nbviewer 的远程服务器上安装了/home/user/nbviewer

[servername]$ python -m nbviewer --debug --no-cache --no-check-certificate --localfiles=/home/user/path/to/notebooks/

这显示了远程服务器上的以下 nbviewer 输出

[I 181122 16:39:17 app:124] Not indexing notebooks
[I 181122 16:39:17 app:128] Not using cache
[I 181122 16:39:17 app:212] Not validating SSL certificates
[W 181122 16:39:17 app:263] Serving local notebooks in /home/user/path/to/notebooks/, this can be a security risk

现在我尝试为笔记本提供服务/home/user/path/to/notebooks/test.ipynb,因此在本地计算机上的浏览器中输入网址

http://servername:5000/localfile/test.ipynb

这给出了 404 错误

[W 181122 16:51:40 log:53] 404 GET /localfile/test.ipynb

正如链接答案中所建议的,我也尝试访问

http://servername:5000/localfile/

查看提供的文件列表,但我再次收到 404 错误。

谢谢您的帮助!

标签: pythonjupyter-notebookjupyter

解决方案


调试后nbviewer/nbviewer/providers/local/handlers.py,我看到如果 nbviewer 没有文件的读取权限,它会发送 404 错误。在我看来应该是 401 Unauthorized 错误,但无论如何,在更改我想要托管的文件的权限后,它起作用了


推荐阅读