Skip to main content

Convert Streamlit Python apps to stlite HTML apps

Project description

🔦 streamlit2stlite

Turn your Streamlit apps into standalone HTML files in seconds.

streamlit2stlite is a simple tool that bundles your Streamlit application and all its dependencies into a single HTML file. This file can be opened in any modern browser, running entirely purely on the client side using WebAssembly (via stlite). No server, no hosting costs, no deployment headaches.

💡 Perfect for sharing data dashboards, prototypes, and tools with colleagues or clients who don't have Python installed.

🎮 Try it now!

Don't want to install anything yet? specific files are included in this repository that you can download and run immediately:

  • Converter Tool (converter_app.html): A self-contained tool that lets you upload and convert other Streamlit apps to HTML directly in your browser.
  • Example App (example_app.html): A simple demo showing what the output looks like.

To use them:

  1. Click the link above (or navigate to the file in the repo).
  2. Download the raw file (on GitHub, click "Download raw file" button).
  3. Open the downloaded .html file in Chrome, Edge, or Firefox.

🚀 Quick Start

  1. Install the tool:

    pip install streamlit2stlite
    
  2. Convert your app:

    streamlit2stlite my_app.py
    
  3. Open my_app.html in your browser. That's it!


✨ Features

  • 📦 Auto-Magic Dependency Detection: Automatically scans your imports to determine which packages to install in the browser (e.g., proper handling of pandas, numpy, scipy for lmfit, etc.).
  • � LaTeX Support: Correctly handles backslashes in your math equations so they render perfectly.
  • �️ Smart Titles: Automatically detects your app's title from st.set_page_config() or st.title().
  • 🛠️ Full Control: Override requirements, titles, or the stlite version via CLI flags if you need to.

� Usage Guide

Basic Conversion

The simplest way to use it. Defaults to creating an HTML file with the same name as your script.

streamlit2stlite dashboard.py
# -> Creates dashboard.html

Custom Output Name

Specify exactly where you want the file to go.

streamlit2stlite script.py -o ./dist/awesome_dashboard.html

Managing Dependencies

We try to guess your dependencies, but sometimes you need to be specific.

Add extra packages:

streamlit2stlite app.py --add-requirements "scikit-learn,purple-air"

Override completely:

streamlit2stlite app.py --requirements "streamlit,pandas,numpy"

Full CLI Options

usage: streamlit2stlite [-h] [-o OUTPUT] [-r REQUIREMENTS] [-t TITLE]
                        [--stlite-version STLITE_VERSION]
                        [--add-requirements ADD_REQUIREMENTS] [-v]
                        input

positional arguments:
  input                 Path to the input Streamlit Python file

options:
  -h, --help            show this help message
  -o, --output          Path to the output HTML file
  -r, --requirements    Comma-separated list of packages to install
  -t, --title           Title for the HTML page
  --add-requirements    Additional packages to add to auto-detected ones
  -v, --verbose         Print verbose output
## ⚠️ Limitations

While running Python in the browser is magical, it has some constraints you should be aware of:

*   **Library Support**: You can only use:
    *   **Pure Python** packages found on PyPI (packages that don't require C compilation).
    *   **Scientific packages** expressly ported to Pyodide (e.g., `numpy`, `pandas`, `scipy`, `matplotlib`, `scikit-learn`).
    *   *System-level* packages like `opencv-python` (cv2) or complex compiled libraries that haven't been ported will **NOT** work.
*   **Performance**: Code runs in the browser, so it's generally slower than native Python. Heavy data processing might lag the UI.
*   **Networking**: Standard `requests` won't work due to browser CORS security. You must use `pyodide.http` or libraries that wrap the browser's `fetch` API.
*   **File System**: No direct access to the user's local hard drive. Use `st.file_uploader` and `st.download_button` to interact with files.

## ❓ FAQ

**How does this work?**
It embeds your Python code into a template that loads `stlite` (a port of Streamlit to WebAssembly). When you open the HTML file, your browser downloads a mini Python environment (Pyodide) and runs your code locally.

**Can I read local files?**
Because this runs in the browser, it cannot read files from your hard drive directly (sandbox security). You should use `st.file_uploader` to let users provide files, or embed data directly into your script.

**Does it support all Python packages?**
It supports packages available in [Pyodide](https://pyodide.org/en/stable/usage/packages-in-pyodide.html) (including numpy, pandas, scipy, matplotlib, scikit-learn) and pure Python packages from PyPI (micropip).

## 📄 License

MIT License. Feel free to use this for whatever you want!

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

streamlit2stlite-0.1.1.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

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

streamlit2stlite-0.1.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file streamlit2stlite-0.1.1.tar.gz.

File metadata

  • Download URL: streamlit2stlite-0.1.1.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for streamlit2stlite-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7273060a21303dbb1c837e1352a6d3c9ae3d40a1e758c19bf897e9a1db2bee82
MD5 2a4b81da6184118ab5f28d7a9a82ca8e
BLAKE2b-256 33eea6417218ac688accde355cbee5b86346f09cc66d31a095458339bc58c754

See more details on using hashes here.

File details

Details for the file streamlit2stlite-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit2stlite-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 acb3bc7bce0eff709c4662658fa20901e3d7e1a102dc7ec56a33cab3024a9125
MD5 3981cec43508ad0a94a7791edcf846b5
BLAKE2b-256 a5cd241ab4f4750f5d804b1f14988fc14aca63e38147d9a5a8d3e6aa91340283

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