我正在尝试弄清楚如何配置运行的 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#
这可能吗?
最佳答案
要更改从 iPython 提供的文件的基本 url,请编辑 ipython_notebook_config.py
文件在你的 ~/.ipython/[profile-name]/
目录。
特别是,假设您的配置文件以行 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/ipython/
开始提供服务而不是 http://localhost:8888/
.
有关详细信息,请参阅 this page of the ipython docs .
关于python - IPython:为所有请求配置基本 Url 路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32468794/