Run IPython Notebook in Iframe from another Domain

2019-06-20 15:28发布

I want to run an IPython notebook that is on my server inside an iframe on another server. I get this error:

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

Here it says I should set some x-frame-header option for this: http://ipython.org/ipython-doc/dev/whatsnew/development.html#iframe-embedding

Where can I set this? How to change this X-Frame-Option so that it can be embedded from another site? :)

1条回答
不美不萌又怎样
2楼-- · 2019-06-20 16:00

Update

according to the comment by Harrison, it should be

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

now, see also http://jupyter-notebook.readthedocs.io/en/stable/config.html

Original Post

Ok I found a solution that is working but I am not 100% sure if it is the right way to do it: In .ipython/your_profile/ipython_notebook_config.py add

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

Works for me, but not sure if this overrides more settings from tornado or anything :)

查看更多
登录 后发表回答