transpolymer commited on
Commit
1402dbb
Β·
verified Β·
1 Parent(s): d6e22d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -17
app.py CHANGED
@@ -1,33 +1,40 @@
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
- # βœ… Page router using a dictionary
11
- PAGES = {
12
- "Home": home,
13
- "Predictions": prediction,
14
- "About": about,
15
- "Contact": contact
16
- }
17
-
18
- # βœ… Sidebar Navigation
19
  st.sidebar.title("πŸ”— Navigation")
20
- page = st.sidebar.radio("Select a Page", list(PAGES.keys()))
21
 
22
- # βœ… URL parameter override (?page=Contact)
23
  query_params = st.query_params
24
  if "page" in query_params:
25
  param_page = query_params["page"][0].capitalize()
26
- if param_page in PAGES:
27
  page = param_page
28
 
29
- # βœ… Load selected page using dictionary
30
- PAGES[page].show()
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
 
33
 
 
1
  import streamlit as st
2
+
3
+ # βœ… This MUST be first!
4
+ st.set_page_config(page_title="TransPolymer", layout="wide", page_icon="πŸ§ͺ")
5
+
6
+ # βœ… Then import your modules
7
  import home
8
  import prediction
9
  import about
10
  import contact
11
 
12
+ # βœ… Navigation Sidebar
 
 
 
 
 
 
 
 
 
 
 
13
  st.sidebar.title("πŸ”— Navigation")
14
+ page = st.sidebar.radio("Select a Page", ["Home", "Predictions", "About", "Contact"])
15
 
16
+ # βœ… Optional: Override from URL like ?page=Contact
17
  query_params = st.query_params
18
  if "page" in query_params:
19
  param_page = query_params["page"][0].capitalize()
20
+ if param_page in ["Home", "Predictions", "About", "Contact"]:
21
  page = param_page
22
 
23
+ # βœ… Page rendering logic
24
+ def load_page(page_name):
25
+ if page_name == "Home":
26
+ home.show()
27
+ elif page_name == "Predictions":
28
+ prediction.show()
29
+ elif page_name == "About":
30
+ about.show()
31
+ elif page_name == "Contact":
32
+ contact.show()
33
+ else:
34
+ st.error("Page not found.")
35
+
36
+ load_page(page)
37
+
38
 
39
 
40