If you’re new to marimo, check out our GitHub repo: marimo is free and open source.
Transform your repository of notebooks into a collection of interactive data apps. In this blog, we’ll explore how to serve your collection of Python notebooks as data apps directly from a GitHub repository using marimo. This is a great demonstration of a few of marimo’s unique features:
- File format: marimo notebooks are just pure Python files (
.py
), ensuring compatibility with modern Python tools likeuv
,docker
, and version control systems. No need for dealing with code buried inside JSON. - ASGI-compatibility: marimo’s server can mount notebooks as web apps on any ASGI server, making it easy to deploy data apps.
- Self-contained: No need for complex configuration files or environment setup - everything is contained in a single Python file.
How It Works
We’ll use marimo’s ASGI server to serve notebooks from a GitHub repository. The server reads notebooks and creates individual marimo apps for each one, all while keeping the code simple and maintainable.
Step 1: Import the Essentials
First, import the necessary libraries:
We’re using PEP 723 to declare our dependencies inline, instead of a separate requirements.txt
. Doing so allows us to run this script directly with uv
without needing a separate requirements file. This is also what powers marimo’s sandboxed notebooks.
Step 2: Download Notebooks from GitHub
Next, download the Python files from the GitHub repository:
This function recursively retrieves all Python files from the specified GitHub repository. Since marimo notebooks are just Python files, we don’t need any special conversion or post-processing.
Step 3: Create a marimo Server
Create a marimo server with each notebook as an app under their respective paths:
marimo’s ASGI server makes it easy to serve multiple notebooks under different paths. Each notebook becomes its own interactive data app, complete with UI elements and reactivity.
Step 4: Set Up the FastAPI App
Set up a FastAPI app to serve as the entry point:
And finally, this block runs the server:
Our template directory has a single file: templates/home.html
, which lists all the apps with a clean UI. You can customize this to your liking. Or even inline it in the script, giving you a single file to run and share.
Now, it can be easily run with:
Bonus: Deploy with Docker
For deployment, you can package your application with Docker:
You can find an example of this setup in our HuggingFace Space.
Conclusion
This guide demonstrates how to build a single-file Python application that serves marimo notebooks from a GitHub repository. Should you use this in production? Probably not. However, this is pretty close; some considerations to make this production-ready:
- Downloading the GitHub files in a build process, not on the fly.
- Installing the dependencies in the Docker build, not the Docker command (e.g.
uv run ...
). - Implementing authentication (marimo has some built-in support).
We’d love to hear what fun ways are you using marimo’s unique features, so please share them with us on Discord!