【问题标题】:Run IPython Notebook in Iframe from another Domain从另一个域的 iframe 中运行 IPython Notebook
【发布时间】:2014-08-15 13:36:17
【问题描述】:

我想在另一台服务器的 iframe 中运行我服务器上的 IPython 笔记本。 我收到此错误:

Refused to display 'my_url/Test.ipynb' in a frame because 
it set 'X-Frame-Options' to 'SAMEORIGIN'

这里说我应该为此设置一些 x-frame-header 选项: http://ipython.org/ipython-doc/dev/whatsnew/development.html#iframe-embedding

在哪里可以设置?如何更改此 X-Frame-Option 以便可以从其他站点嵌入? :)

【问题讨论】:

    标签: iframe ipython ipython-notebook


    【解决方案1】:

    更新

    根据哈里森的评论,应该是

    c.NotebookApp.tornado_settings = {'headers': {'X-Frame-Options': 'ALLOW-FROM https://example.com/'}}
    

    现在,另见http://jupyter-notebook.readthedocs.io/en/stable/config.html

    原帖

    好的,我找到了一个可行的解决方案,但我不能 100% 确定它是否是正确的方法: 在 .ipython/your_profile/ipython_notebook_config.py 添加

    c.NotebookApp.webapp_settings = {'headers': {'X-Frame-Options': 'ALLOW-FROM https://example.com/'}}
    

    对我有用,但不确定这是否会覆盖来自龙卷风或其他任何东西的更多设置 :)

    【讨论】:

    • webapp_settings 现在已弃用。而是使用tornado_settings
    • webapp_settingswebapp_settings 对我不起作用。
    • 不幸的是我不再使用这个所以不知道可能是什么问题:(
    【解决方案2】:

    一种简单的方法是使用“细胞魔法”%%html 将 iframe 嵌入到 jupyter 细胞中

    示例:

    %%html
    <iframe width="500" height="350" src="https://www.youtube.com/embed/vTingdk_pVM" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
    

    【讨论】:

    • 谢谢,请注意,我想在另一台服务器上的 iframe 中运行笔记本,而不是在笔记本中运行 iframe。
    猜你喜欢
    • 2013-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-16
    • 2014-06-18
    • 2013-06-06
    • 1970-01-01
    • 2015-05-04
    相关资源
    最近更新 更多