【发布时间】:2016-07-26 06:08:36
【问题描述】:
我希望我自己的代码编辑器通过 jupyter notebook 执行代码,并且必须在我的 Web 应用程序 UI 中显示结果
【问题讨论】:
标签: javascript web-applications jupyter-notebook code-editor
我希望我自己的代码编辑器通过 jupyter notebook 执行代码,并且必须在我的 Web 应用程序 UI 中显示结果
【问题讨论】:
标签: javascript web-applications jupyter-notebook code-editor
最简单的方法是将整个页面嵌入iframe:
<iframe src="http://localhost:8888" />
需要注意的一点是,Jupyter notebook 默认只允许同源页面嵌入,方法是在 header 中设置frame-ancestors:
'headers': {
'Content-Security-Policy': "frame-ancestors 'self'"
}
为了嵌入到你自己的应用程序中,你需要覆盖jupyter_notebook_config.py中的设置以允许任何页面嵌入它:
c.NotebookApp.tornado_settings = {
'headers': {
'Content-Security-Policy': "frame-ancestors *"
}
}
【讨论】:
iframes?