Skip to main content

Streamlit Static Export

This library will allow Titles, Paragraphs, Dataframes and Altair Charts to be exported into a static HTML file.

PyPi Project

You can access the PyPi project here

Installation

pip install st-static-export

Available Methods

  • add_header : Creates a H1-H4 title.
  • export_dataframe : Creates a HTML table from your dataframe that can be optionally enclosed in an expander.
  • add_text: Allows for a paragraph to be added to the HTML export.
  • export_altair_graph: Embeds an Altair chart, including interactions and selections to your HTML file.
  • create_html: composes final HTML file and returns a string or bytes.

Usage

import streamlit as st
import st_static_export as sse
import pandas as pd
import altair as alt

#This can be read from a separate file
css_text = """
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
tr:nth-child(even) {background-color: #f2f2f2;}
.table{
    width:100%;
}
.footn{
color:#c0c0c0;
}
"""
#Initialize StreamlitStaticExport

static_html = sse.StreamlitStaticExport(css=css_text)
static_html.add_header(id="title",text="Seattle Weather", size="H1" )
static_html.add_header(id="subtitle",text="Dataset from Vegas", size="H3" )
st.title("Seattle Weather")
html.add_text(id="explanation", text="""This is a brief explanation of \n how Seattle weather behaves""", text_class='footn')
df = local_data.seattle_weather()
st.dataframe(df)
html.export_dataframe(id="df", dataframe=df,inside_expandable=True, table_class='table')
base = alt.Chart(df).mark_bar().encode(
    x=alt.X('date', type='temporal'),
    y=alt.Y('precipitation', type='quantitative'),
    color = alt.Color('weather', type ='nominal')
)
st.altair_chart(base, use_container_width=True)

html.export_altair_graph(id="chart",html_content=base.properties(width=900))

#Return a string
str_result = html.create_html(return_type="String")
with open('sample.html', 'w') as b: 
    b.write(str_result)

#Return Bytes to be attached to a button or other actions. 
bt_result = html.create_html(return_type="Bytes")
with open('sample_bytes.html', 'wb') as b: 
    b.write(bt_result)

sample

Output

sample

Metadata

Release files for st-static-export 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for st-static-export 0.2.0
File Size Uploaded Provenance
st_static_export-0.2.0.tar.gz 4.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for st-static-export 0.2.0
File Interpreter ABI Platform
st_static_export-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.2 kB

Release files / st_static_export-0.2.0.tar.gz

Download URL st_static_export-0.2.0.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
797599bd372d8f25d7ff3073d22a90d950b18fb9b4cdb936a2abf6dbb475a7f0
BLAKE2b-256 checksum
How to use checksums
d004fa5e1a7e7e5e567adab4825d88b11ca9880d9805b333cb3e71c315cbc4f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / st_static_export-0.2.0-py3-none-any.whl

Download URL st_static_export-0.2.0-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9cb0d9acff34bef1a7e89d1b54bea31d413bb0e08e6f95cf15429088a67788f4
BLAKE2b-256 checksum
How to use checksums
9103040ed5b7083b98a70691f210cf820cc49ccb61a5ed7a7231fdc66fefa280
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Security for st-static-export 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page