Skip to content

Install

H2O Nitro can be installed from PyPI:

pip install "h2o-nitro[web]"

Prerequisites

You will need Python 3.7 or later installed on your system.

Hello World!

To build apps with Nitro, you'll also need to install one of Flask, Tornado, or Starlette to host WebSocket connections.

Using Flask

Download hello_flask.py, then:

# Create a virtual environment
python3 -m venv venv
source venv/bin/activate

# Install Nitro and Flask:
pip install "h2o-nitro[web]" flask simple-websocket

# Run the app:
python hello_flask.py
:: Create a virtual environment and activate:
python -m venv env
.\env\Scripts\activate

:: Install Nitro and Flask:
pip install "h2o-nitro[web]" flask simple-websocket

:: Run the app:
python hello_flask.py

Play with the app

Go to http://localhost:5000/.

Using Tornado

Download hello_tornado.py, then:

# Create a virtual environment
python3 -m venv venv
source venv/bin/activate

# Install Nitro and Tornado:
pip install "h2o-nitro[web]" tornado

# Run the app:
python hello_tornado.py
:: Create a virtual environment and activate:
python -m venv env
.\env\Scripts\activate

:: Install Nitro and Tornado:
pip install "h2o-nitro[web]" flask simple-websocket

:: Run the app:
python hello_tornado.py

Play with the app

Go to http://localhost:5000/.

Using Starlette

Download hello_starlette.py, then:

# Create a virtual environment
python3 -m venv venv
source venv/bin/activate

# Install Nitro and Starlette:
pip install "h2o-nitro[web]" uvicorn starlette websockets

# Run the app:
python -m uvicorn hello_starlette:app --reload --port 5000
:: Create a virtual environment and activate:
python -m venv env
.\env\Scripts\activate

:: Install Nitro and Starlette:
pip install "h2o-nitro[web]" uvicorn starlette websockets

:: Run the app:
python -m uvicorn hello_starlette:app --reload --port 5000

Play with the app

Go to http://localhost:5000/.

Summary

Nitro is a library, and plugs into Flask, Tornado, Starlette and other popular frameworks.

There's no need to start a brand new project either, you can easily use it in your existing applications, too!

Next steps