Mahadih534 commited on
Commit
d013bae
·
verified ·
1 Parent(s): e467858

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -12
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
- st.title("Streamlit App with Embedded Chainlit UI")
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("Waiting for Chainlit app to start..."):
37
  while True:
38
  try:
39
  response = requests.get(chainlit_url)
40
  if response.status_code == 200:
41
- break # Chainlit is ready
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("Chainlit app did not start in time.")
54
  st.stop()
55
 
56
- st.success("Chainlit app loaded!")
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