-
Notifications
You must be signed in to change notification settings - Fork 0
/
navigation.py
41 lines (29 loc) · 1.1 KB
/
navigation.py
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
# load the required dependencies
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:
if st.session_state.get('logged_in', False):
st.page_link('pages/Home.py', label='Data Extraction', icon='📄')
st.page_link('pages/Dashboard.py', label='Dashboard', icon='📊')
st.write('')
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')