A smooth local reader for saved Jupyter notebooks with lazy media output streaming.
Project description
ipynb-local-viewer
A smooth, local-first reader for saved Jupyter notebooks.
ipynb-local-viewer turns an .ipynb file into a fast reading surface: markdown
headings become an outline, outputs are shown first, code is collapsed behind
syntax-highlighted expandable blocks, and large images or videos are loaded
through lazy streamed asset URLs instead of being embedded into the main page
payload.
It reads saved notebooks only. It does not execute code.
Features
- Markdown-derived outline with smooth section navigation.
- Lazy image and video output loading for media-heavy notebooks.
- Collapsed code cells with Pygments syntax highlighting.
- Safe sanitized HTML output rendering with Bleach.
- Light, dark, and device theme modes.
- Local Flask server with no frontend build step.
- Root-restricted notebook access for safer local browsing.
- Small decoded media cache for faster repeat reads.
Install
python -m pip install ipynb-local-viewer
For local development from a checkout:
python -m pip install -e .
Quick Start
Open a notebook on http://localhost:8770:
notebook-viewer --notebook analysis.ipynb --port 8770
Restrict the viewer to a specific project directory:
notebook-viewer --root ~/projects/my-analysis --notebook notebooks/report.ipynb --port 8770
Start without opening a browser:
notebook-viewer --root . --notebook analysis.ipynb --port 8770 --no-browser
Stop a foreground server with Ctrl-C.
CLI
notebook-viewer [--root ROOT] [--notebook NOTEBOOK] [--host HOST] [--port PORT] [--no-browser]
Options:
--root: directory that readable notebooks must stay inside, default.--notebook: notebook path relative to--root--host: bind host, default0.0.0.0--port: bind port, default8770--no-browser: do not open a browser automatically
How It Works
The viewer parses saved notebook JSON with the Python standard library and
caches parsed notebooks by path, mtime, and size. Markdown headings define the
outline. Selecting or scrolling to a section loads the cells for that section,
while image and video outputs are represented as asset descriptors and streamed
separately from /api/asset/<asset_id>.
Supported output behavior:
- PNG, JPEG, GIF, SVG, and common video MIME outputs become lazy asset URLs.
- HTML video data URLs are extracted into streamed video assets.
- HTML tables and rich HTML outputs are sanitized before rendering.
- stdout, stderr, tracebacks, and unsupported widgets use readable fallback blocks.
- Code cells include raw source and highlighted HTML in the section API.
API
The local server exposes a small JSON/asset API:
GET /api/notebooks: list.ipynbfiles under--rootGET /api/notebook?path=...: return outline and section metadataGET /api/section?path=...§ion=...: return cells for one sectionGET /api/asset/<asset_id>: stream decoded media assets
Notebook and section JSON responses avoid embedding large base64 media payloads.
Security Notes
ipynb-local-viewer is a local reader, not a notebook execution environment.
- It never runs notebook code.
- It restricts notebook access to the configured
--root. - It sanitizes markdown-rendered HTML and notebook HTML outputs.
- It serves decoded media assets from
.notebook_viewer_cache/.
As with any local web server, bind it only where you intend to expose it. The
default host is 0.0.0.0; use --host 127.0.0.1 for loopback-only access.
Development
Install development tools and run the test suite:
python -m pip install -e .
python -m pip install build twine trove-classifiers tomli
python -m unittest discover -s tests
python -m compileall src
Build and validate distribution artifacts:
python -m build
python -m twine check dist/*
python scripts/check_classifiers.py
Publishing
Releases are intended to use PyPI Trusted Publishing from GitHub Actions.
One-time PyPI setup:
- Log into the PyPI account
masoudka. - Create or select the PyPI project
ipynb-local-viewer. - Add a pending trusted publisher for:
- Owner:
msdkhairi - Repository:
ipynb-viewer - Workflow:
release.yml - Environment:
pypi
- Owner:
Owner is the GitHub repository owner, not the PyPI username. The GitHub
repository can remain ipynb-viewer even though the PyPI distribution name is
ipynb-local-viewer.
Release flow:
git tag v0.1.0
git push origin v0.1.0
Then create a GitHub release for that tag. The release workflow builds the artifacts, validates them, and publishes with PyPI Trusted Publishing.
Manual fallback:
python -m build
python -m twine check dist/*
python -m twine upload dist/*
License
ipynb-local-viewer is distributed under the MIT License. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ipynb_local_viewer-0.1.0.tar.gz.
File metadata
- Download URL: ipynb_local_viewer-0.1.0.tar.gz
- Upload date:
- Size: 25.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
891ef4ec00299334e327f06f4d33f3f6aebaed3a9445012d572399914a1fe0b7
|
|
| MD5 |
261fc9653282652b1506697459113f73
|
|
| BLAKE2b-256 |
a46c96ae84ce99ae90e77325c12731bdd3732d03984d366e87d959a0acd1142f
|
Provenance
The following attestation bundles were made for ipynb_local_viewer-0.1.0.tar.gz:
Publisher:
release.yml on msdkhairi/ipynb-viewer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ipynb_local_viewer-0.1.0.tar.gz -
Subject digest:
891ef4ec00299334e327f06f4d33f3f6aebaed3a9445012d572399914a1fe0b7 - Sigstore transparency entry: 1397892258
- Sigstore integration time:
-
Permalink:
msdkhairi/ipynb-viewer@bf54e04d08c70cad3b8c2be95079b0ad8e67108a -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/msdkhairi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bf54e04d08c70cad3b8c2be95079b0ad8e67108a -
Trigger Event:
release
-
Statement type:
File details
Details for the file ipynb_local_viewer-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ipynb_local_viewer-0.1.0-py3-none-any.whl
- Upload date:
- Size: 24.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6eabbba81f8263e48c97f2dd129a452125186efcbe93e2db90017679dab937a
|
|
| MD5 |
a4fc617ba7286ddcb37e691ebbc7836b
|
|
| BLAKE2b-256 |
de9d5bc585658d0553c3bfd0b0374a5c7ed7bab69666081381446b081bb90ef8
|
Provenance
The following attestation bundles were made for ipynb_local_viewer-0.1.0-py3-none-any.whl:
Publisher:
release.yml on msdkhairi/ipynb-viewer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ipynb_local_viewer-0.1.0-py3-none-any.whl -
Subject digest:
b6eabbba81f8263e48c97f2dd129a452125186efcbe93e2db90017679dab937a - Sigstore transparency entry: 1397892486
- Sigstore integration time:
-
Permalink:
msdkhairi/ipynb-viewer@bf54e04d08c70cad3b8c2be95079b0ad8e67108a -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/msdkhairi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bf54e04d08c70cad3b8c2be95079b0ad8e67108a -
Trigger Event:
release
-
Statement type: