Examples
Static notebook

Turn notebook to static website

You can turn Python notebooks to static websites. Please create App object with satic_notebook=True. This will display your notebook as a static website. What is more, you can control whether to show or hide code.

Required packages

You need to install mercury package to run this example.

Notebook

Import needed packages:

import mercury as mr

Setup App with static_notebook=True:

app = mr.App(title="Static notebook",
             description="Display notebook as static website",
             show_code=True,
             static_notebook=True)

Other cells with code:

a = 1
 
b = 2
 
print(f"a + b is {a+b}")

The screenshot with code:

Python notebook with static option

Mercury App

Please start Mercury in the same directory as notebook:

mercury run

When you open a notebook you should see:

Mercury App with static notebook

The notebook can be downloaded as PDF or HTML file.

Additional tips

  • You can hide sidebar by setting app = mr.App(show_sidebar=False, ... other arguments ).
  • You can hide Download button in the sidebar by setting app = mr.App(allow_download=False, ... other agruments).
  • Mercury App display notebook in full screen mode. You can set 1140px as width for notebook displayed in Mercury by setting app = mr.App(full_screen=False, ... other arguments).

Please check App documentation for details.