Hosting interactive jupyter notebook on private website
Asked Answered
P

3

14

I currently run a personal website using Wordpress (but hosted on siteground) that is a set of engineering study guides. I would like to move towards making these study guides interactive (i.e. refreshing graphics based on sliders, doing basic calculations to indicate if a design works or not, so I need numpy). A friend recommended that I utilize Jupyter notebooks for this purpose, as you can both render LaTeX (which I'm currently using Mathjax with Wordpress to do), as well as have the types of interactive graphics I want using either Bokeh or Plotly.

While I've seen tutorials for sharing notebooks on specific servers, what I'm after is being able for others to run my notebook in their browser (read-only), where the notebook is privately hosted.

I'm still not sure if Jupyter is the correct avenue to accomplish what I want, so I'm open to other suggestions (someone also recommended using Julia, but I've seen fewer examples of this).

Phyliciaphylis answered 17/4, 2018 at 8:54 Comment(5)
I also have this question. did you find an answer?Gayomart
@EB88, no such luck so far.Phyliciaphylis
shame. Have you tried JupyterHub? This achieves my aim - in your case you could host a jupyter notebook in an iframe. This won't work for me as I need to use a Windows machine to host, which isn't supported by JupyterHubGayomart
@Gayomart I'm aware of JupyterHub, but I would like to use my own server (since I'm already paying for it), and I'm wary of if JupyterHub becomes a subscription service. The closest "how to" for what I'm trying to do that I've found so far is for JuliaPhyliciaphylis
I doubt JupyterHub will become subscription based. It is currently open sourced so you could download the code now and run the JupyterHub to serve your notebooks on your own private server if that makes sense. From the documentation: "The JupyterHub server can be on an internal network at your organization, or it can run on the public internet (in which case, take care with the Hub's security)."Gayomart
E
6

I agree with your friend that Jupyter Notebooks is an excellent approach. And while it's by no means the only method to accomplish what you're after, I'm hard-pressed to come up with an immediate alternative that doesn't require significant work to set up.

I can think of three primary methods of using Jupyter Notebooks which suit your needs:

1. Azure Notebooks

Microsoft has a new service called Azure Notebooks, which is (currently) totally free.

Azure Notebooks boasts the complete functionality of Jupyter Notebooks, and in addition to Python, users can also program cells in R and F#. As for typical usage of the service, here's a snippet from their FAQ:

Jupyter (formerly IPython), is a multi-lingual REPL on steroids. This is a free service that provides Jupyter notebooks along with supporting packages for R, Python and F# as a service. This means you can just login and get going since no installation/setup is necessary. Typical usage includes schools/instruction, giving webinars, learning languages, sharing ideas, etc. The service is provided by the Python team @ Microsoft, which is part of the Data Group.

2. nbviewer

The top banner of the main Jupyter site contains a link link to an application called nbviewer.

Evidently, you can create your markdown / Jupyter syntax as a discrete page somewhere else, feed the URL to your page into nbviewer, and it'll render it for you right there in the results. If I were going to use this, I would either;

  • Create a discrete WordPress page for my Jupyter syntax, then feed that into nbviewer; or, more likely
  • Use GitHub to host my Jupyter Notebook pages (mainly for posterity and version control, over the Gist option), and use the raw text link as the source to feed into nbviewer.

3. Hosting Your Own Solution

If you're technically savy enough, I'd recommend this approach over nbviewer.

When you launch Jupyter Notebooks on your own machine, you access it through your browser using the default URL of http://localhost:8888. That means there must exist some mechanism to expose that port to external users, and allow them to have access to your Notebook, using the exact same interface. Two methods of doing so:

  1. Using Jupyter Notebooks public server
  2. Remotely accessing your normal Jupyter Notebook

Hope that helps! I'm curious to know if any of these options works out for you.

Engvall answered 6/7, 2018 at 22:56 Comment(1)
So after a little more searching, I also found nbviewer, but there is also nbinteract. I think this might be the path of least resistance for getting my guides updated (at least for now).Phyliciaphylis
R
1

The Iodide Project (and subsequently, Pyodide) are two projects that aim to allow this. They're still in development, but might be worth looking into.

Rafaelle answered 11/1, 2019 at 14:21 Comment(2)
pyodide link is deadStrapped
And iodide is apparently "no longer under development"Strapped
A
0

You can try to use Mercury framework. It allows you to transform notebooks into web applications (with interactive widgets). You need to add YAML header to the beginning of the notebook. Based on YAML the widgets will be generated. Your users can change widgets values and click Run button to execute the notebook with new inputs. You can decide whether to show or hide code for your users. You can serve multiple notebooks with Mercury on single server. It is based on Django so can be easily deployed on any server/cloud.

The example notebook:

example notebook

The generated application for the above notebook:

mercury app

The screenshot of app/notebooks gallery in the Mercury:

app gallery in Mercury

Arva answered 8/2, 2022 at 16:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.