import streamlit as st import streamlit.components.v1 as components import subprocess import time import requests hide_streamlit_style = """ """ st.markdown(hide_streamlit_style, unsafe_allow_html=True) chainlit_url = f"https://reasoning-app-m7ew.onrender.com/" timeout = 60 # Maximum wait time in seconds start_time = time.time() # Create a progress bar and a placeholder for status messages 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 # app is ready except Exception: pass # Keep waiting if there's an error (e.g., connection refused) elapsed = time.time() - start_time # Update progress (capped at 100%) 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("") # Embed the Chainlit app using an iframe # components.iframe(chainlit_url, width=800) html_code = f""" """ st.markdown(html_code, unsafe_allow_html=True)