Spaces:
Running
Running
import streamlit as st | |
# β Must be the first command | |
st.set_page_config(page_title="TransPolymer", layout="wide", page_icon="π§ͺ") | |
# β Import your page modules | |
import home | |
import prediction | |
import about | |
import contact | |
# β Navigation Sidebar | |
st.sidebar.title("π Navigation") | |
page = st.sidebar.radio("Select a Page", ["Home", "Predictions", "About", "Contact"]) | |
# β Optional: Override via URL (?page=Contact) | |
query_params = st.query_params | |
if "page" in query_params: | |
param_page = query_params["page"][0].capitalize() | |
if param_page in ["Home", "Predictions", "About", "Contact"]: | |
page = param_page | |
# β Page loading logic | |
def load_page(page_name): | |
if page_name == "Home": | |
home.show() | |
elif page_name == "Predictions": | |
prediction.show() | |
elif page_name == "About": | |
about.show() | |
elif page_name == "Contact": | |
contact.show() | |
else: | |
st.error("Page not found.") | |
# β Load the selected page | |
load_page(page) | |