|
import streamlit as st |
|
import streamlit.components.v1 as components |
|
import subprocess |
|
import time |
|
import requests |
|
|
|
hide_streamlit_style = """ |
|
<style> |
|
/* Hide the hamburger menu */ |
|
#MainMenu {visibility: hidden;} |
|
/* Hide the header */ |
|
header {visibility: hidden;} |
|
/* Hide the footer */ |
|
footer {visibility: hidden;} |
|
</style> |
|
""" |
|
st.markdown(hide_streamlit_style, unsafe_allow_html=True) |
|
|
|
|
|
|
|
chainlit_url = f"https://mute-wave-0666.ploomber.app/" |
|
timeout = 60 |
|
start_time = time.time() |
|
|
|
|
|
progress_bar = st.progress(0) |
|
status_text = st.empty() |
|
|
|
with st.spinner("Please wait to prepare the app..."): |
|
while True: |
|
try: |
|
response = requests.get(chainlit_url) |
|
if response.status_code == 200: |
|
break |
|
except Exception: |
|
pass |
|
|
|
elapsed = time.time() - start_time |
|
|
|
progress = min(int((elapsed / timeout) * 100), 100) |
|
progress_bar.progress(progress) |
|
status_text.text(f"Waiting... {int(elapsed)} seconds elapsed.") |
|
time.sleep(1) |
|
|
|
if elapsed > timeout: |
|
st.error("main app did not start in time.") |
|
st.stop() |
|
|
|
st.success("App loaded!") |
|
status_text.text("") |
|
|
|
|
|
|
|
html_code = f""" |
|
<style> |
|
.full-screen-iframe {{ |
|
position: fixed; |
|
top: 0; |
|
left: 0; |
|
width: 100vw; |
|
height: 100vh; |
|
border: none; |
|
z-index: 9999; |
|
}} |
|
</style> |
|
<iframe src="{chainlit_url}" class="full-screen-iframe"></iframe> |
|
""" |
|
|
|
st.markdown(html_code, unsafe_allow_html=True) |
|
|