python - IPython:为所有请求配置基本 Url 路径

标签 python ipython

我正在尝试弄清楚如何配置运行的 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/

相关文章:

ipython - Canopy 中的 QT Shell

python - ValueError : Variable d_w1/Adam/does not exist, 或不是用 tf.get_variable() 创建的

python - 为什么 find_all 会报错,即使 just find 没有报错? ( python 美汤)

ipython - 如何在 Ipython Notebook 上使用我的 GPU?

matplotlib - 发出 show() 后不会出现图形窗口

python - 如何使 IPython 笔记本 matplotlib 绘图内联

python - 了解 numpy.where

python - cv2.imwrite 不保存图像

python - Pyspark 等同于 Pyodbc?

ipython - 使用目录将IPython笔记本编写为HTML或PDF