transpolymer commited on
Commit
fd6f526
Β·
verified Β·
1 Parent(s): 787cc39

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -15
app.py CHANGED
@@ -1,21 +1,34 @@
1
  import streamlit as st
2
- from home import show_home
3
- from prediction import show_prediction
4
- from contact import show_contact
5
- from about import show_about
6
 
 
7
  st.set_page_config(page_title="TransPolymer", layout="wide", page_icon="πŸ§ͺ")
8
 
9
- # Sidebar for navigation
10
  st.sidebar.title("πŸ”— Navigation")
11
- page = st.sidebar.radio("Go to", ["Home", "Prediction", "Contact Us", "About"])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
- # Routing logic
14
- if page == "Home":
15
- show_home()
16
- elif page == "Prediction":
17
- show_prediction()
18
- elif page == "Contact Us":
19
- show_contact()
20
- elif page == "About":
21
- show_about()
 
1
  import streamlit as st
2
+ import home
3
+ import prediction
4
+ import about
5
+ import contact
6
 
7
+ # Set page config
8
  st.set_page_config(page_title="TransPolymer", layout="wide", page_icon="πŸ§ͺ")
9
 
10
+ # Navigation menu
11
  st.sidebar.title("πŸ”— Navigation")
12
+ page = st.sidebar.radio("Select a Page", ["Home", "Predictions", "About", "Contact"])
13
+
14
+ # Handle URL query params (e.g., ?page=Contact)
15
+ query_params = st.query_params
16
+ if "page" in query_params:
17
+ page = query_params["page"][0].capitalize() # Capitalize to match the radio button options
18
+
19
+ # Page routing logic
20
+ def load_page(page_name):
21
+ if page_name == "Home":
22
+ home.show()
23
+ elif page_name == "Predictions":
24
+ prediction.show()
25
+ elif page_name == "About":
26
+ about.show()
27
+ elif page_name == "Contact":
28
+ contact.show()
29
+ else:
30
+ st.error("Page not found")
31
+
32
+ # Load the selected page
33
+ load_page(page)
34