IPython:为所有请求配置基本URL路径

9

我正在尝试弄清楚如何配置运行的IPython笔记本服务器的基本URL。 因此,而不是默认值:

#request# GET http://localhost:8888/static/tree/js/main.min.js?v=04a28c5e21950738efb217191f08ac33
#request# GET http://localhost:8888/api/terminals?_=1441754529652
#request# GET http://localhost:8888/custom/custom.js?v=20150908160654
#request# GET http://localhost:8888/notebooks/Untitled1.ipynb?kernel_name=python3#

我希望配置所有请求,以便它们通过 ipython 进行,例如:

#request# GET http://localhost:8888/ipython/static/tree/js/main.min.js?v=04a28c5e21950738efb217191f08ac33
#request# GET http://localhost:8888/ipython/api/terminals?_=1441754529652
#request# GET http://localhost:8888/ipython/custom/custom.js?v=20150908160654
#request# GET http://localhost:8888/ipython/notebooks/Untitled1.ipynb?kernel_name=python3#

这个可能吗?
1个回答

6

如果要更改从iPython提供的文件的基本url,请编辑~/.ipython/[profile-name]/目录下的ipython_notebook_config.py文件。

特别是,假设您的配置文件以c = get_config()开头,您将需要将以下行添加到您的配置中:

c.NotebookApp.base_project_url = '/ipython/'
c.NotebookApp.base_kernel_url = '/ipython/'
c.NotebookApp.webapp_settings = {'static_url_prefix':'/ipython/static/'}

这样做可以使您的项目从http://localhost:8888/变为http://localhost:8888/ipython/

更多信息请参见ipython文档中的此页面


NotebookApp.webapp_settings现已弃用。 - sprksh
将上述评论补充为:c.NotebookApp.base_project_url也已被弃用,现在使用c.ServerApp.base_url。 - Illegal Operator

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接