Streamlit on Jupyterhub

This release adds Streamlit to JupyterHub, making it easier to build and run interactive data applications directly from the JupyterHub environment.

Streamlit is a Python framework that turns Python scripts into interactive web applications. With Streamlit available in JupyterHub, you can build dashboards, forms, charts, and data exploration tools using familiar Python code and libraries.

1. What Is Streamlit?

Streamlit lets you create web applications directly from Python without building a separate frontend. You write a Python script, use Streamlit components such as text inputs, tables, and charts, and Streamlit renders the app in a browser.

2. Why Use It in JupyterHub

Streamlit is useful in JupyterHub for several common workflows:

  • building dashboards from data already accessible in the JupyterHub environment
  • creating lightweight internal tools and interactive reports
  • moving notebook logic into a more shareable application format
  • building interactive UIs with Python only

3. Getting Started

Unlike a notebook workflow, Streamlit apps are created as Python scripts. There is no separate default staging app or special launcher tile required for this workflow. To get started, create your own .py file, add import streamlit as st, and run it from JupyterHub.

Example

The following example creates a simple Streamlit app with a title, a text input, and a small table:

Bash
Copy

Save the script as something like my_app.py.

3.1 Example: Query Hive and Display Results

For a more realistic JupyterHub use case, the following example connects to Spark with Hive support, lets you choose a database and table, and displays a sample of the results in the Streamlit app.

Bash
Copy

Save above to something like teststreamlit.py and in terminal in jupyterhub, run streamlit run hivestreamlit.py specify port if required

This example is useful for lightweight data exploration and internal reporting workflows where Hive data is already available in the JupyterHub environment.

4. Running Your App

4.1 Create Your Application File

Create a Python file for your app, such as my_app.py, and add your Streamlit code there. This is the main workflow for building Streamlit apps in JupyterHub.

4.2 Run via JupyterHub CLI

Run the application from a terminal in JupyterHub:

Bash
Copy

This starts the Streamlit app using your JupyterHub environment so you can open it in the browser and interact with it.

4.4 Iterate on Your App

As you update and save your Python script, Streamlit can automatically refresh the app, making it easy to iterate on layouts, widgets, and visualizations during development.

Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard
  Last updated