Mercury documentation
Mercury is an open-source (opens in a new tab) framework that helps you build web applications from your Jupyter Notebooks.
You can create with Mercury:
Mercury modes
Mercury offers set of widgets with simple re-execution of cells in the notebook.
Development in Jupyter Notebook
Mercury comes with set of Input Widgets and Output Widgets. You can interact with widgets during notebook development.
Widgets values will be automatically updated. However, cells below the widget definition code will not be automatically executed (you need to run them manually).
Run notebook as Web App in Mercury
Serve notebook as web application with Mercury. Any widget update will trigger automatic re-execution of cells. Not all cells are re-executed. Only cells with widget definition and below are re-executed.
It allows to speed-up computation and cache previous results.
Installation
Please install Mercury with the following command:
pip install mercury
# or
conda install -c conda-forge mercuryStart Mercury Server:
mercury runRun Mercury demo:
mercury run demoImport Mercury Widgets with the following code:
import mercury as mrRun demo notebooks
Mercury comes with built-in demo notebooks. You can play with them by running:
mercury run demoThe above command will create demo notebooks and start development server. Please check the Mercury website at http://127.0.0.1:8000.
You need to have installed pandas, numpy and matplotlib to run demo notebooks.
Quick Start
Let's build a very simple web app with Mercury. Please create a new Python notebook with the following three code cells.
Import Mercury package
import mercury as mrAdd text widget
name = mr.Text(label="What is your name?")Print widget value
print(f"Hello {name.value}!")Please run the following command in the same directory as notebook:
mercury runYou should see in the web browser at address http://127.0.0.1:8000 a Mercury website with your notebook.