Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,39 +1,40 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
from login import login
|
| 3 |
-
from signup import signup
|
| 4 |
import home
|
| 5 |
-
import prediction
|
| 6 |
import about
|
| 7 |
import contact
|
|
|
|
| 8 |
|
| 9 |
-
#
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
if st.session_state
|
| 17 |
-
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
|
|
|
| 26 |
|
| 27 |
-
|
|
|
|
| 28 |
home.show()
|
| 29 |
-
elif page == "
|
| 30 |
prediction.show()
|
| 31 |
-
elif page == "About":
|
| 32 |
about.show()
|
| 33 |
-
elif page == "
|
| 34 |
contact.show()
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
else:
|
| 38 |
-
if login(): # This now returns True when credentials are correct
|
| 39 |
-
st.session_state.logged_in = True
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
|
|
|
| 2 |
import home
|
| 3 |
+
import prediction
|
| 4 |
import about
|
| 5 |
import contact
|
| 6 |
+
import login_page as login # Renamed login.py to login_page.py for clarity and to avoid naming conflicts
|
| 7 |
|
| 8 |
+
# β
Must be first Streamlit command
|
| 9 |
+
st.set_page_config(page_title="TransPolymer", layout="wide", page_icon="π§ͺ")
|
| 10 |
+
|
| 11 |
+
# β
Ensure users collection exists
|
| 12 |
+
login.create_users_collection()
|
| 13 |
|
| 14 |
+
# β
Initialize login state
|
| 15 |
+
if "logged_in" not in st.session_state:
|
| 16 |
+
st.session_state.logged_in = False
|
| 17 |
|
| 18 |
+
# β
Show login or main app
|
| 19 |
+
if not st.session_state.logged_in:
|
| 20 |
+
login.show_login_page()
|
| 21 |
+
else:
|
| 22 |
+
# β
Load Home page immediately after login
|
| 23 |
+
if "page" not in st.session_state:
|
| 24 |
+
st.session_state.page = "Home"
|
| 25 |
|
| 26 |
+
# β
Sidebar navigation appears only after login
|
| 27 |
+
st.sidebar.title("π Navigation")
|
| 28 |
+
st.session_state.page = st.sidebar.radio("Select a Page", ["Home", "Predictions", "About", "Help"], index=["Home", "Predictions", "About", "Help"].index(st.session_state.page))
|
| 29 |
|
| 30 |
+
# β
Load page dynamically
|
| 31 |
+
if st.session_state.page == "Home":
|
| 32 |
home.show()
|
| 33 |
+
elif st.session_state.page == "Predictions":
|
| 34 |
prediction.show()
|
| 35 |
+
elif st.session_state.page == "About":
|
| 36 |
about.show()
|
| 37 |
+
elif st.session_state.page == "Help":
|
| 38 |
contact.show()
|
| 39 |
+
else:
|
| 40 |
+
st.error("Page not found.")
|
|
|
|
|
|
|
|
|