-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstreamlit_dash_app.py
38 lines (32 loc) · 1010 Bytes
/
streamlit_dash_app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import streamlit as st
import threading
import time
import subprocess
import requests
# Function to start the Dash app
def start_dash():
subprocess.Popen(["python", "dash_app.py"])
# Function to check if the Dash app is running
def check_dash():
while True:
try:
response = requests.get("http://localhost:8050")
if response.status_code == 200:
break
except requests.exceptions.ConnectionError:
pass
time.sleep(1)
# Start the Dash app in a separate thread
threading.Thread(target=start_dash).start()
# Check if the Dash app is running before embedding it
check_dash()
# Display the Dash app in an iframe within Streamlit
st.title("Dash App in Streamlit")
st.write("This is an example of embedding a Dash app within Streamlit.")
# Embed the Dash app using an iframe
st.markdown(
"""
<iframe src="http://localhost:8050" width="100%" height="800" style="border:none;"></iframe>
""",
unsafe_allow_html=True
)