Spaces:
Sleeping
Sleeping
File size: 1,281 Bytes
d03e822 677b1e2 d03e822 169fbc0 d03e822 677b1e2 |
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 43 44 45 |
import streamlit as st
from time import sleep
from streamlit.runtime.scriptrunner import get_script_run_ctx
from streamlit.source_util import get_pages
def get_current_page_name():
ctx = get_script_run_ctx()
if ctx is None:
raise RuntimeError("Couldn't get script context")
pages = get_pages("")
return pages[ctx.page_script_hash]["page_name"]
def make_sidebar():
with st.sidebar:
st.title("Your Jobs Finder")
st.write("")
st.write("")
if st.session_state.get("logged_in", False):
st.page_link("pages/page1.py", label="Find Your Jobs")
st.page_link("pages/page2.py", label="Account")
if st.session_state.user == "jobadmin":
st.page_link("pages/admin.py", label="admin")
st.write(f"Hello {st.session_state.user}")
st.write("")
if st.button("Log out"):
logout()
elif get_current_page_name() != "app":
# If anyone tries to access a secret page without being logged in,
# redirect them to the login page
st.switch_page("app.py")
def logout():
st.session_state.logged_in = False
st.info("Logged out successfully!")
sleep(0.5)
st.switch_page("app.py")
|