Display HTML file with JS inside iPython laptop

I have a piece of code in an iPython laptop that programmatically creates a folder called β€œsound” that contains the following files: index.html, canvas.js, graph.js and style.css.

If I open index.html in my browser, I can see exactly the result that I want: a graph with nice JS animation representing vectors in and out of the process that I am modeling.

network visualization

However, I would like to display the HTML file inside the iPython notebook itself.

To do this, I print the following code:

from IPython.display import IFrame IFrame('/Users/useird/Desktop/sound/index.html', width=700, height=350) 

Which returns the following: 404 error ipython notebook

I'm not an expert with css or js, but I think that iPython can display js inside an iframe, so what is wrong here?

thanks

+6
source share
1 answer

To explicitly answer this question, I leave my comment here.

IPython uses the Tornado web server engine to serve html pages. By default, the web server cannot access files above the start directory. Otherwise, it will be a serious security risk. Therefore, in order to make your data available to the web server, you must put it in the start directory of the laptop or in a subdirectory.

This applies not only to html pages, but also to the images you want to display with tags.

+6
source

Source: https://habr.com/ru/post/982813/


All Articles