Update app.py
Browse files
app.py
CHANGED
@@ -16,16 +16,9 @@ hide_streamlit_style = """
|
|
16 |
"""
|
17 |
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
|
18 |
|
19 |
-
# Define the port for Chainlit (ensure it's different from Streamlit's port)
|
20 |
-
chainlit_port = "8000"
|
21 |
-
chainlit_command = ["chainlit", "run", "cl_app.py", "--port", chainlit_port]
|
22 |
|
23 |
-
# Start the Chainlit app as a subprocess
|
24 |
-
chainlit_process = subprocess.Popen(chainlit_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
chainlit_url = f"http://0.0.0.0:{chainlit_port}"
|
29 |
timeout = 60 # Maximum wait time in seconds
|
30 |
start_time = time.time()
|
31 |
|
@@ -33,12 +26,12 @@ start_time = time.time()
|
|
33 |
progress_bar = st.progress(0)
|
34 |
status_text = st.empty()
|
35 |
|
36 |
-
with st.spinner("
|
37 |
while True:
|
38 |
try:
|
39 |
response = requests.get(chainlit_url)
|
40 |
if response.status_code == 200:
|
41 |
-
break #
|
42 |
except Exception:
|
43 |
pass # Keep waiting if there's an error (e.g., connection refused)
|
44 |
|
@@ -50,10 +43,10 @@ with st.spinner("Waiting for Chainlit app to start..."):
|
|
50 |
time.sleep(1)
|
51 |
|
52 |
if elapsed > timeout:
|
53 |
-
st.error("
|
54 |
st.stop()
|
55 |
|
56 |
-
st.success("
|
57 |
status_text.text("")
|
58 |
|
59 |
# Embed the Chainlit app using an iframe
|
|
|
16 |
"""
|
17 |
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
|
18 |
|
|
|
|
|
|
|
19 |
|
|
|
|
|
20 |
|
21 |
+
chainlit_url = f"https://mute-wave-0666.ploomber.app/"
|
|
|
|
|
22 |
timeout = 60 # Maximum wait time in seconds
|
23 |
start_time = time.time()
|
24 |
|
|
|
26 |
progress_bar = st.progress(0)
|
27 |
status_text = st.empty()
|
28 |
|
29 |
+
with st.spinner("Please wait to prepare the app..."):
|
30 |
while True:
|
31 |
try:
|
32 |
response = requests.get(chainlit_url)
|
33 |
if response.status_code == 200:
|
34 |
+
break # app is ready
|
35 |
except Exception:
|
36 |
pass # Keep waiting if there's an error (e.g., connection refused)
|
37 |
|
|
|
43 |
time.sleep(1)
|
44 |
|
45 |
if elapsed > timeout:
|
46 |
+
st.error("main app did not start in time.")
|
47 |
st.stop()
|
48 |
|
49 |
+
st.success("App loaded!")
|
50 |
status_text.text("")
|
51 |
|
52 |
# Embed the Chainlit app using an iframe
|