eagle0504 commited on
Commit
7649bad
·
verified ·
1 Parent(s): e738b80

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -0
app.py CHANGED
@@ -1,2 +1,51 @@
1
  import streamlit as st
2
  import streamlit_authenticator as stauth
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  import streamlit_authenticator as stauth
3
+ import yaml
4
+ from yaml.loader import SafeLoader
5
+ with open('../config.yaml') as file:
6
+ config = yaml.load(file, Loader=SafeLoader)
7
+
8
+ authenticator = Authenticate(
9
+ config['credentials'],
10
+ config['cookie']['name'],
11
+ config['cookie']['key'],
12
+ config['cookie']['expiry_days'],
13
+ config['preauthorized']
14
+ )
15
+
16
+ name, authentication_status, username = authenticator.login('Login', 'main')
17
+
18
+
19
+ if authentication_status:
20
+ authenticator.logout('Logout', 'main')
21
+ st.write(f'Welcome *{name}*')
22
+ st.title('Some content')
23
+ elif authentication_status == False:
24
+ st.error('Username/password is incorrect')
25
+ elif authentication_status == None:
26
+ st.warning('Please enter your username and password')
27
+
28
+
29
+ if st.session_state["authentication_status"]:
30
+ authenticator.logout('Logout', 'main')
31
+ st.write(f'Welcome *{st.session_state["name"]}*')
32
+ st.title('Some content')
33
+ elif st.session_state["authentication_status"] == False:
34
+ st.error('Username/password is incorrect')
35
+ elif st.session_state["authentication_status"] == None:
36
+ st.warning('Please enter your username and password')
37
+
38
+
39
+ name, authentication_status, username = authenticator.login('Login', 'main')
40
+ if authentication_status:
41
+ authenticator.logout('Logout', 'main')
42
+ if username == 'jsmith':
43
+ st.write(f'Welcome *{name}*')
44
+ st.title('Application 1')
45
+ elif username == 'rbriggs':
46
+ st.write(f'Welcome *{name}*')
47
+ st.title('Application 2')
48
+ elif authentication_status == False:
49
+ st.error('Username/password is incorrect')
50
+ elif authentication_status == None:
51
+ st.warning('Please enter your username and password')