Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,37 +1,39 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
st.set_page_config(page_title="TransPolymer", layout="wide", page_icon="π§ͺ")
|
| 5 |
-
|
| 6 |
-
# β
Import your page modules
|
| 7 |
import home
|
| 8 |
-
import prediction
|
| 9 |
import about
|
| 10 |
import contact
|
| 11 |
|
| 12 |
-
#
|
| 13 |
-
st.
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
if "page" in query_params:
|
| 19 |
-
param_page = query_params["page"][0].capitalize()
|
| 20 |
-
if param_page in ["Home", "Predictions", "About", "Help"]:
|
| 21 |
-
page = param_page
|
| 22 |
|
| 23 |
-
|
| 24 |
-
def load_page(page_name):
|
| 25 |
-
if page_name == "Home":
|
| 26 |
home.show()
|
| 27 |
-
elif
|
| 28 |
prediction.show()
|
| 29 |
-
elif
|
| 30 |
about.show()
|
| 31 |
-
elif
|
| 32 |
contact.show()
|
| 33 |
-
else:
|
| 34 |
-
st.error("Page not found.")
|
| 35 |
|
| 36 |
-
#
|
| 37 |
-
|
|
|
|
|
|
|
|
|
| 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 |
+
# Initialize session state
|
| 10 |
+
if 'logged_in' not in st.session_state:
|
| 11 |
+
st.session_state.logged_in = False
|
| 12 |
+
if 'signup' not in st.session_state:
|
| 13 |
+
st.session_state.signup = False
|
| 14 |
+
|
| 15 |
+
# Sign-up flow
|
| 16 |
+
if st.session_state.signup:
|
| 17 |
+
signup()
|
| 18 |
+
|
| 19 |
+
# Logged-in flow
|
| 20 |
+
elif st.session_state.logged_in:
|
| 21 |
+
st.sidebar.title("Navigation")
|
| 22 |
+
page = st.sidebar.radio("Go to", ("Home", "Prediction", "About", "Contact"))
|
| 23 |
|
| 24 |
+
if st.sidebar.button("Logout"):
|
| 25 |
+
st.session_state.logged_in = False
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
+
if page == "Home":
|
|
|
|
|
|
|
| 28 |
home.show()
|
| 29 |
+
elif page == "Prediction":
|
| 30 |
prediction.show()
|
| 31 |
+
elif page == "About":
|
| 32 |
about.show()
|
| 33 |
+
elif page == "Contact":
|
| 34 |
contact.show()
|
|
|
|
|
|
|
| 35 |
|
| 36 |
+
# Login flow
|
| 37 |
+
else:
|
| 38 |
+
if login(): # This now returns True when credentials are correct
|
| 39 |
+
st.session_state.logged_in = True
|