Hi everyone, I’ve discovered something interesting while trying to embed an external Streamlit page inside a local Streamlit page. Apparently, if the page I embed is a local Streamlit page, there’s no problem. But if it’s something I’ve uploaded to Streamlit Share cloud, it won’t let me embed it. I’ll show the code and the difference between both (url doesnt work, but url_local does):
import streamlit as st
import streamlit.components.v1 as components
#example of streamlit share public page
url = 'https://nl2sql.streamlit.app/'
#a local but different streamlit page
url_local = 'http://192.168.1.150:8501/
#using iframe markdown
st.markdown(f'<iframe src={url} width="100%" height="600" style="position:absolute; top:200px; left:0; overflow:hidden; margin-top:-300px;"></iframe>', unsafe_allow_html=True)
st.markdown(f'<iframe src={url_local} width="100%" height="600" style="position:absolute; top:200px; left:0; overflow:hidden; margin-top:-300px;"></iframe>', unsafe_allow_html=True)
#using components
st.components.v1.iframe(url, width=None, height=600)
st.components.v1.iframe(url_local, width=None, height=600)
No matter what streamlit website I embed or what browser I use: If it’s a local streamlit page it will work just fine, but it it’s an external streamlit, mine or not, it just don’t work, even if it’s excactly the same code.
Of course, if you visit the website using the real URL and not embed, it also works.
Any Ideas?