Skip to main content

A JupyterLab extension for serving web app.

Project description

jupyterpack

Github Actions Status Try on lite

A JupyterLite extension to serve in-browser Python and Javascript web application

Features

  • Python Web Apps: Serve Python web applications directly in the browser using JupyterLite's in-browser Python kernel. jupyterpack currently supports Dash, Streamlit and Shiny for Python. You can also use jupyterpack to serve any asgi or wsgi Python web application. .
  • JavaScript Web Apps: Bundle and serve JavaScript web applications using in-browser bundlers.

Image

Installation

You can install jupyterpack using pip or conda

# Install using pip
pip install jupyterpack

# Install using conda
conda install -c conda-forge jupyterpack

Usage

To use jupyterpack, you need to create a .spk file that defines your web application. Here's an example structure of a React application:

my_app/
├── app.spk
├── App.js         # Your JS code
├── package.json   # Your JS dependencies
└── index.html      # HTML entry for JS apps

the app.spk is the entry point of your React app, it should contain the following content:

{
  "name": "React Example",
  "entry": "/index.html",
  "framework": "react"
}

Double-clicking the spk file to open the web app as a tab of JupyterLab.

.spk — Jupyter Pack File Format

A .spk file describes how an application should be loaded, executed, and rendered in JupyterLite and JupyterLab.
It defines the entry point, framework, optional dependencies, and runtime metadata, allowing reproducible execution across environments.

The file is expressed in JSON.

Basic Structure

interface IJupyterPackFileFormat {
  entry: string;
  framework: JupyterPackFramework;
  name?: string;
  metadata?: {
    autoreload?: boolean;
  };
  rootUrl?: string;
  dependencies?: IDependencies;
  disableDependencies?: boolean;
}
  • entry (required): Path to the main entry file of the application. For examples:

    • "app.py"
    • "/index.html"
    • "dashboard/index.py"

    The path is resolved relative to the .spk file location.

  • framework (required): The framework used to run the application. Supported frameworks are:

    Value Description
    react React-based frontend application
    dash Plotly Dash application
    streamlit Streamlit application
    tornado Tornado web application
    shiny Shiny application (Python)
    starlette Starlette ASGI application
  • name (optional): The name of the application. If not provided, the name will be the name of the .spk file.

  • metadata (optional): Additional metadata for the application.

    • autoreload: Enables automatic reload when source files change.
  • rootUrl (optional): The root URL of the web application. Default is /

  • dependencies (optional): The dependencies of the web application. It will be merged with the default dependencies of the selected framework

    • mamba: Emscripten-forge packages
    • pip: PYPI packages Example:
      dependencies: {
        mamba: ['numpy, scipy'];
        pip: ['plotly'];
      }
      

    You only need to specify the dependencies of the application, the required dependencies of the framework will be automatically added.

  • disableDependencies (optional): Disable entirely the dependency installation. This is useful when dependencies are already provided by the environment. Default is false.

Full example

{
  "name": "Sales Dashboard",
  "entry": "app.py",
  "framework": "streamlit",
  "rootUrl": "/",
  "metadata": {
    "autoreload": true
  },
  "dependencies": {
    "mamba": ["numpy", "pandas"],
    "pip": []
  }
}

Framework-specific configurations

Dash application

Same as the React application, here is the structure of a Dash application:

my_app/
├── app.spk
├── server.py         # Your Dash code

the app.spk is the entry point of your Dash app, it should contain the following content:

{
  "name": "Dash Example",
  "entry": "server.py",
  "framework": "dash"
}

For Dash applications, you must define your Dash instance as a variable named app.
Do not call app.run_server() yourself — jupyterpack is responsible for starting and managing the server lifecycle.

As with React applications, double-clicking the .spk file will open the Dash app in a new JupyterLab tab.

Streamlit application

Streamlit applications follow a similar structure to Dash apps. Write your code as a standard Streamlit application and do not start the server manually — jupyterpack will handle execution and serving automatically.

Opening the .spk file will launch the Streamlit app in a new JupyterLab tab.

Shiny application

Shiny applications also follow a structure similar to Dash apps.
jupyterpack supports both Shiny Express and Shiny Core applications.

  • Shiny Express: no special requirements.
  • Shiny Core: the application instance must be assigned to a variable named app.

In both cases, the server is managed by jupyterpack, and opening the .spk file will launch the app in JupyterLab.

Try it online!

You can try it online by clicking on this badge:

Try on lite

License

jupyterpack is licensed under the BSD-3-Clause license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupyterpack-0.5.2.tar.gz (204.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jupyterpack-0.5.2-py3-none-any.whl (131.0 kB view details)

Uploaded Python 3

File details

Details for the file jupyterpack-0.5.2.tar.gz.

File metadata

  • Download URL: jupyterpack-0.5.2.tar.gz
  • Upload date:
  • Size: 204.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for jupyterpack-0.5.2.tar.gz
Algorithm Hash digest
SHA256 993383cf9600540f6cee741bcfc6e34e5ceca12fa9aaf5b72487158e1a635afe
MD5 2d3321530eb6c98ad29f3e3488a536bb
BLAKE2b-256 a2ddba14cff8f4ba9131ecc5ee055383ce441b81249a9276fafe2f254485f219

See more details on using hashes here.

File details

Details for the file jupyterpack-0.5.2-py3-none-any.whl.

File metadata

  • Download URL: jupyterpack-0.5.2-py3-none-any.whl
  • Upload date:
  • Size: 131.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for jupyterpack-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 46a6af1d09e3ef50ce8ae972f965570d8127a3233e66b86c1c2d4009504fdd26
MD5 a6bbc8200e469fde9d2cfd2579e532cc
BLAKE2b-256 ce43d4cbb491f7dbd5c404c19d0d5381c4de4482f1553f2aeb9e5c719dae5f66

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page