Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import streamlit as st
|
2 |
import streamlit_antd_components as sac
|
3 |
|
@@ -19,18 +20,24 @@ with st.sidebar:
|
|
19 |
]),
|
20 |
], open_all=True)
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
# Link to the respective pages using exec
|
23 |
if menu_item == 'Home':
|
24 |
st.write("Home Page")
|
25 |
-
|
26 |
elif menu_item == 'Apple':
|
27 |
st.write("Apple Page")
|
28 |
-
|
29 |
elif menu_item == 'Google':
|
30 |
st.write("Google Page")
|
31 |
-
|
32 |
elif menu_item == 'Products':
|
33 |
st.write("Products Page")
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
1 |
+
import os
|
2 |
import streamlit as st
|
3 |
import streamlit_antd_components as sac
|
4 |
|
|
|
20 |
]),
|
21 |
], open_all=True)
|
22 |
|
23 |
+
# Function to load and execute a file if it exists
|
24 |
+
def exec_file(file_path):
|
25 |
+
if os.path.exists(file_path):
|
26 |
+
with open(file_path) as f:
|
27 |
+
exec(f.read(), globals())
|
28 |
+
else:
|
29 |
+
st.error(f"File not found: {file_path}")
|
30 |
+
|
31 |
# Link to the respective pages using exec
|
32 |
if menu_item == 'Home':
|
33 |
st.write("Home Page")
|
34 |
+
exec_file('folder/pages/home.py')
|
35 |
elif menu_item == 'Apple':
|
36 |
st.write("Apple Page")
|
37 |
+
exec_file('folder/apple.py')
|
38 |
elif menu_item == 'Google':
|
39 |
st.write("Google Page")
|
40 |
+
exec_file('folder/pages/google.py')
|
41 |
elif menu_item == 'Products':
|
42 |
st.write("Products Page")
|
43 |
+
exec_file('folder/pages/products.py')
|
|
|
|