I would like the following to happen when I visit a wordpress site:
- the WP page displays up to date data and cells from a Jupyter Notebook
- That notebook has api calls and database calls that feed visualizations.
How do I do this? Does wordpress need to make an ajax call to a JupyterHub server and the server then runs the notebook, saves the ipynb file, and converts the ipynb file to html and then sends it back to wordpress evertime the wordpress page is refreshed? If so, how does it do this?
You do not need a Hub for that, have a look into nbconvert: https://nbconvert.readthedocs.io/en/latest/
But how will the python in the jupyter notebook actually run? Where will it run? Say the server jupyter notebook has credentials that are needed to access the database and they are stored as environment variables. Wordpress won’t have access to that right?
Just to clear things up: Do you want “interactive” cells in a WP page, or do you want a “dynamic” WP page that is “executed like a notebook and then shown”?
The latter! everytime the notebook is opened or the page refreshed, the data is fresh because the code executes and if the code involves an api call or database call, it’s made then and there.
The thing is, what if the api call involves credentials? How would wordpress even handle that?
If you click “Restart and Run All” in a Notebook, Jupyter is more or less doing what nbconvert would do. The difference is that Jupyter would display it, while nbconvert produces a “flat” HTML file.
Depending on the task, you can run a cronjob to produce that “flat” HTML, or you can point WordPress via PHP to run it every time and display it afterwards.
What I do if I want to embed an interactive Jupyter Notebook on Wordpress?