Spaces:
Running
Running
File size: 1,299 Bytes
1002edf d9a46f2 7b3033f 1402dbb 7b3033f fd6f526 7b3033f 1402dbb 7b3033f d9a46f2 7b3033f c748d73 7b3033f c748d73 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
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":
# Add user input for SMILES here
smiles = st.text_input("Enter SMILES for polymer prediction:")
if smiles: # Only call prediction.show() if SMILES is provided
prediction.show(smiles) # Pass SMILES to the prediction function
else:
st.write("Please enter a valid SMILES string.")
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) |