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
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?
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. http://10.12.200.18:8000/website/assets/..., 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.
Hi @tim, I want to open an index.html file that contains Js code for d3.js visualization. When I used streamlit locally, I started http server and with webbrower.open_new_tab(http://localhost:8000/index.html), I was able to open the visualization. However when I deployed the app on share streamlit, I couldnt do that. When I click on the button, no new tab appears. Could you please explain to me more how to fix that, I am barely new to deployement . I would really appreciate it.
Hey @ghass002 - Streamlit sharing doesn’t do any direct hosting of HTML files, so this approach won’t work. However, Streamlit now has the ability to embed HTML directly into an app:
import streamlit as st
html_string = ... # load your HTML from disk here
st.html(html_string)
Hey Gotticketsto360tour. I am running to the same issue with Streamlit.
here is my current code. Any idea on how I can display it in Streamlit app?
lda_model = gensim.models.ldamodel.LdaModel(corpus=corpus, id2word=id2word, num_topics=5, random_state=1, update_every=1, chunksize=100, passes=10, alpha=‘auto’, per_word_topics=True)
import pyLDAvis
import pyLDAvis.gensim_models as gensimvis
vis = gensimvis.prepare(lda_model, corpus, id2word)
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.