Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I embed an Ipython Notebook in an iframe (new)

Tags:

python

ipython

I have successfully achieved this using the method documented at Run IPython Notebook in Iframe from another Domain . However, this required editing the user config file. I was really hoping to be able to set this up via the command-line instead (for reasons).

http://ipython.org/ipython-doc/1/config/overview.html indicates that configuration via the command line is possible. However, all the examples are for simple true/false value assignment. To set the server up to allow embedding, it is necessary to set a value inside a dictionary. I can't work out how to pass a dictionary in through the command-line.

Another acceptable option would be a configuration overrides file.

Some people will wonder -- why all this trouble!?!

First of all, this isn't for production. I'm trying to support non-developers by writing a web-based application which integrates Ipython notebooks within it using iframes. Despite being on the same machine, it appears that the different port number used is enough to mean that I can't do simple iframe embedding without setting the x-frame insecurity bit.

Being able to do this via the command line lets me set the behaviour in the launch script rather than having to bundle a special configuration file inside my app, and also write an installer.

I really hope I've make the question clear enough! Thanks for any and all suggestions and help!

like image 663
Tennessee Leeuwenburg Avatar asked Oct 18 '14 02:10

Tennessee Leeuwenburg


1 Answers

Looking over the IPython source for the loaders, it seems like it will execute whatever python code you put on the right hand side. I've not tested it, but based on the link you provided, you can probably pass something like

--NotebookApp.webapp_settings=dict('headers'=dict('X-Frame-Options'='ALLOW-FROM https://example.com/'))
like image 199
cm2 Avatar answered Oct 13 '22 19:10

cm2