Skip to content

Examples

It's easy to run these examples on your computer.

  1. Install the nitro CLI.
  2. Create and switch to a new directory, say, nitro_examples.
  3. Execute nitro run http://path/to/example.py.

Info

If you run multiple examples from the same working directory, nitro run will reuse the virtual environment already present in that directory.

Tip

If you simply want to fetch, but not run the example, use nitro clone instead of nitro run.

Basic Examples

Hello World using Flask

A simple app, using Flask.

Source: https://github.com/h2oai/nitro/blob/main/py/demo/hello_flask.py

Run

nitro run https://raw.githubusercontent.com/h2oai/nitro/main/py/demo/hello_flask.py

Hello World using Tornado

Same example as above, but using Tornado.

Source: https://github.com/h2oai/nitro/blob/main/py/demo/hello_tornado.py

Run

nitro run https://raw.githubusercontent.com/h2oai/nitro/main/py/demo/hello_tornado.py

Hello World using Starlette

Same example as above, but using Starlette and Uvicorn.

Source: https://github.com/h2oai/nitro/blob/main/py/demo/hello_starlette.py

Run

nitro run https://raw.githubusercontent.com/h2oai/nitro/main/py/demo/hello_starlette.py

Apply for space flight

A job application wizard. Seven pages in seven statements!

Source: https://github.com/h2oai/nitro/blob/main/py/demo/space_flight.py

Run

nitro run https://raw.githubusercontent.com/h2oai/nitro/main/py/demo/space_flight.py

Back button state handling

How to track state when the user clicks back/forward to navigate between pages.

Source: https://github.com/h2oai/nitro/blob/main/py/demo/back_button.py

Run

nitro run https://raw.githubusercontent.com/h2oai/nitro/main/py/demo/back_button.py

Data Visualization

Using Matplotlib

How to use Matplotlib in Nitro apps.

Source: https://github.com/h2oai/nitro-matplotlib/blob/main/examples/matplotlib_basic.py

Run

nitro run https://raw.githubusercontent.com/h2oai/nitro-matplotlib/main/examples/matplotlib_basic.py

Using Seaborn

How to use Seaborn in Nitro apps.

Source: https://github.com/h2oai/nitro-matplotlib/blob/main/examples/seaborn_basic.py

Run

nitro run https://raw.githubusercontent.com/h2oai/nitro-matplotlib/main/examples/seaborn_basic.py

Using Bokeh

How to use Bokeh in Nitro apps.

Source: https://github.com/h2oai/nitro-bokeh/blob/main/examples/bokeh_basic.py

Run

nitro run https://raw.githubusercontent.com/h2oai/nitro-bokeh/main/examples/bokeh_basic.py

Using Altair

How to use Altair in Nitro apps.

Source: https://github.com/h2oai/nitro-altair/blob/main/examples/altair_basic.py

Run

nitro run https://raw.githubusercontent.com/h2oai/nitro-altair/main/examples/altair_basic.py