Rendering html file using streamlit app


If we have some static html, probably with some javascript as well, we can deploy the html and use streamlit app to render the html file.

Recomend to have a virtual python environment first, then install the streamlit as:

pip install streamlit

Here’s an example of how your Python script might look:

import streamlit as st
import streamlit.components.v1 as components

# Read the HTML file
with open('your_html_file.html', 'r') as file:
html_content = file.read()

# Render the HTML
components.html(html_content, height=600)

Finally, to test the above python file locally:

streamlit run your_app.py

Author: robot learner
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint policy. If reproduced, please indicate source robot learner !
  TOC