【问题标题】:Is there way to Integrate Jupyter note book to my web application有没有办法将 Jupyter 笔记本集成到我的 Web 应用程序中
【发布时间】:2016-07-26 06:08:36
【问题描述】:

我希望我自己的代码编辑器通过 jupyter notebook 执行代码,并且必须在我的 Web 应用程序 UI 中显示结果

【问题讨论】:

    标签: javascript web-applications jupyter-notebook code-editor


    【解决方案1】:

    最简单的方法是将整个页面嵌入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?
    猜你喜欢
    • 1970-01-01
    • 2018-04-27
    • 1970-01-01
    • 2016-04-28
    • 2017-05-27
    • 2021-02-16
    • 1970-01-01
    • 2023-02-22
    • 1970-01-01
    相关资源
    最近更新 更多