Spaces:
Running
Running
import streamlit as st | |
# --- Page Configuration (Optional but good practice) --- | |
st.set_page_config( | |
page_title="BIOLAB", | |
page_icon=":computer:", | |
layout="wide", | |
#initial_sidebar_state="collapsed" | |
) | |
hardcodedlogin_user={ | |
"usernames":["admin"], | |
"passwords":["123"] | |
} | |
def authenticate_user(username,password): | |
if username in hardcodedlogin_user["usernames"] and password in hardcodedlogin_user["passwords"]: | |
return True | |
else: | |
return False | |
def LOGIN(): | |
st.title("π Authentication System") | |
tab1, tab2 = st.tabs(["Login"]) | |
with tab1: | |
st.subheader("Login to the application") | |
with st.form("login_form"): | |
username = st.text_input("Username") | |
password = st.text_input("Password", type="password") | |
login_button = st.form_submit_button("Login") | |
if login_button: | |
if username and password: | |
status = authenticate_user(username, password) | |
if status==True: | |
st.session_state.logged_in = True | |
st.session_state.username = username | |
st.rerun() | |
else: | |
st.error(message) | |
else: | |
st.warning("Please enter both username and password") | |
def APP(): | |
tab1, tab2, tab3 = st.tabs(["BIOLAB", "OPERATIONS", "OUTPUT"]) | |
with tab1: | |
console_container = st.container(height=150, border=True) | |
with console_container: | |
st.code(">>> System Online...", language="bash") # Use st.code for a console look | |
user_input = st.text_input( | |
"Protein Engineering Query", | |
placeholder="Type something lengthy here... It could be code, a story, or just a lot of thoughts." | |
) | |
if st.button("Execute", use_container_width=True): | |
if user_input: | |
# Simulate processing and append to the console | |
with console_container: | |
st.markdown(f"**>>> Processing input...**") | |
st.code(f"Input received ({len(user_input)} characters):\n{user_input[:200]}...", language="text") # Show first 200 chars | |
st.success("Task completed!") | |
else: | |
with console_container: | |
st.warning(">>> Please enter some text before processing.") | |
with tab2: | |
st.markdown("### Operations") | |
with tab3: | |
st.markdown("### Output") | |
#Route to appropriate page based on login status | |
if st.session_state.logged_in: | |
APP() | |
else: | |
LOGIN() |