Showing a pyLDAvis html

Hello there! May i ask on streamlit, is it possible to render a pyLDAvis HTML on the streamlit app itself?

I have tried importing the html file as a string and st.write with it, but it doesn’t show anything. And from what i understand on the HTML issue that was posted on github, JS is still not enabled yet.

The next alternative I have to show this html is to insert it as a hyperlink like this

However, it is not able to open up the HTML file that I have locally, with a 404: Not Found error. Clicking the redirect link brings me to, as my html file is under the folder website/assets.

Is there anyconfiguration that I can make to Streamlit (currently using v50.2) to make either rendering JS / redirect link in markdown for pyLDAvis to show up?

Thank you!

Hi @lyqht - Streamlit doesn’t currently support embedding HTML/js, but we’re thinking about ways to implement this safely and sanely. (There’s a ticket we just opened to track one particular way this might be done, using iframes, here.)

Re: your link to another HTML file - out of the box, Streamlit does not (currently) support serving files from your filesystem. This functionality is also under consideration, but in the meantime you have a few options:

  • Host your static files via a second webserver. For example, you could use Python’s built-in http.server to accomplish this. Note that this server will have to run on a different port from Streamlit, so your links to website/assets will have to include the port that you start the separate server from (e.g., if you run the server on port 8000.)
  • Modify the Streamlit code to support serving static files. There’s a Gist that demonstrates this and a feature request for supporting file serving directly in Streamlit, if you’re interested in following progress on that.