Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to embed an interactive Jupyter notebook into html?

I am trying to create a web application that allows users to create and share Jupyter notebooks.

Currently, I have JupyterHub up and running and am able to spawn new servers for individual servers.

However, I do not know how to embed a Jupyter notebook into a html page. I have tried nbconvert, but that gives me a static rendering of the noteboo. What I need is a dynamic notebook that users can edit and run.

I plan to store notebooks in GitHub and allow users to view them through the web application.

I have seen something similar to this in the website Quantopian. (Ex : Quantopian notebook). How do I achieve something similar to this on the front-end side of things?

Any help would be greatly appreciated!

like image 798
mintchip36 Avatar asked Jul 29 '17 02:07

mintchip36


People also ask

Can I embed Jupyter Notebook in website?

By default, JupyterLite ships with a Python kernel powered by Pyodide and IPython, bringing a wide variety of features from code completion to interactive visualizations. The latest releases of JupyterLite now ship with a REPL application by default, that you can embed in any website.

How do I turn a Jupyter Notebook into HTML?

Jupyter Notebook's Built-In Capability: If including code, this is the easiest way to create the JNaaP. This method is as simple as clicking File, Download as, HTML (. html). Jupyter will then download the notebook as an HTML file to wherever the browser defaults for downloaded files.

Can we use Jupyter Notebook for HTML?

Notebooks may be exported to a range of static formats, including HTML (for example, for blog posts), reStructuredText, LaTeX, PDF, and slide shows, via the nbconvert command. Furthermore, any . ipynb notebook document available from a public URL can be shared via the Jupyter Notebook Viewer <nbviewer>.

Can Jupyter notebooks be interactive?

Jupyter Notebook has support for many kinds of interactive outputs, including the ipywidgets ecosystem as well as many interactive visualization libraries.


1 Answers

To embed the Jupyter environment, you may consider to use an iframe.

  • Note that current browsers require correct configuration of the Content Security Policy (CSP) of your applications (your custom-Jupyter) to run.
  • You can activate the Developer's console in your browser (e.g. in Chrome) to check the CSP errors that may occur.
  • There are two issues (the one and the other) in Github which responses show you how to deal with that configuration.

To read and store your notebooks in Github, you probably need to check other projects such as mybinder and Everware, and/or modify the source code of your custom-Jupyter.

  • You may check a "cost estimation" example using mybinder. The mybynder is configured to show an specific Github repository. It starts a docker single-user Jupyter server and shows an interactive session in your browser. There are other examples here and here.
  • The source code of mybinder is in Github
  • I think you may consider the Everware project (in beta at this moment) too. The source code is in Github.
like image 169
Jaime Avatar answered Oct 07 '22 00:10

Jaime