Convert Plotly Dash App To Static HTML File
Project description
Dash2HTML Library
Overview
The dash2html library provides a convenient way to convert a Dash web application into a static HTML site. This library enables developers to host static versions of their Dash applications, making them accessible without requiring a running server.
Features
- Dynamic to Static Conversion: Converts Dash applications into static HTML sites with all necessary assets bundled.
- Downloadable Archive: Automatically packages the static site into a ZIP file for easy distribution.
- Self-Contained Static Site: Ensures all required assets (e.g., JavaScript, CSS) are included in the archive.
How to Use
-
Import the Library: Import the
dash2htmlfunction into your project.pip install dash2html
from dash import Dash from dash2html import dash2html
-
Set Up Your Dash Application: Create and configure your Dash app as you normally would.
-
Call
dash2html: Pass your Dash application instance and the desired port number to thedash2htmlfunction:from dash import Dash from your_library import dash2html app = Dash(__name__) # Define your app layout and callbacks here dash2html(app, port=8080)
-
Access the Application:
- Start the server by running your script.
- Visit the URL displayed in the console (e.g.,
http://127.0.0.1:8080) to load the app.
-
Download the Static Site:
- After the app is loaded, navigate to
http://127.0.0.1:8080/download_zip. - The static site will be packaged into a ZIP file and downloaded.
- After the app is loaded, navigate to
Example Workflow
-
Run the Script:
python your_script.py -
Visit the Dash App: Open the app in your browser using the URL provided in the console (e.g.,
http://127.0.0.1:8080). -
Download Static Site: Navigate to
http://127.0.0.1:8080/download_zipin your browser to download the ZIP file.
Notes
- Ensure that the Dash application is running and fully loaded in your browser before downloading the static site.
- The static site will be packaged as
static_site.zipin the current working directory.
Troubleshooting
-
No Content in ZIP: Ensure the Dash app has been loaded in the browser before accessing the
/download_zipendpoint. -
Port Already in Use: Change the
portparameter in thedash2htmlfunction to an available port.
Acknowledgments
Inspired by Ref code Created by Sheth Jenil
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 dash2html-1.tar.gz.
File metadata
- Download URL: dash2html-1.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e96257bebeb5dda745d623d9f24ed47343a9959788a40a829a7dac09017e0fa
|
|
| MD5 |
7d983aa1249e89486f47383ea5bf1afc
|
|
| BLAKE2b-256 |
2988bf4065049152a9348e4e78f7786e21620a9e4bdd8af6031588f3edd789cd
|
File details
Details for the file dash2html-1-py3-none-any.whl.
File metadata
- Download URL: dash2html-1-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
483be71b20edefd36553088ac5ee078fff641f66caea8565909de45a2937a0a1
|
|
| MD5 |
34c3afe883cf976f8d67f6efefaec044
|
|
| BLAKE2b-256 |
1fcc62cee098d2555ef37338ab2b947f41e254ca52d66d2f2beb825f6dc10dd1
|