Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,39 +1,35 @@
|
|
1 |
import streamlit as st
|
2 |
import streamlit_authenticator as stauth
|
|
|
|
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
},
|
12 |
-
"cookie": {
|
13 |
-
"expiry_days": 30,
|
14 |
-
"key": "my_secret_key",
|
15 |
-
"name": "streamlit_auth",
|
16 |
-
},
|
17 |
-
}
|
18 |
-
|
19 |
-
# Initialize the authenticator
|
20 |
authenticator = stauth.Authenticate(
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
25 |
)
|
26 |
|
27 |
-
|
28 |
-
name, authentication_status, username = authenticator.login("Login", location="main")
|
29 |
|
30 |
if authentication_status:
|
31 |
-
st.
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
36 |
elif authentication_status == False:
|
37 |
-
st.error(
|
38 |
elif authentication_status == None:
|
39 |
-
st.warning(
|
|
|
1 |
import streamlit as st
|
2 |
import streamlit_authenticator as stauth
|
3 |
+
import yaml
|
4 |
+
from yaml.loader import SafeLoader
|
5 |
|
6 |
+
|
7 |
+
# --- YAML CONFIG FOR CREDENTIALS ---
|
8 |
+
with open('./config.yaml') as file:
|
9 |
+
config = yaml.load(file, Loader=SafeLoader)
|
10 |
+
|
11 |
+
|
12 |
+
# Authenticator setup
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
authenticator = stauth.Authenticate(
|
14 |
+
config['credentials'],
|
15 |
+
config['cookie']['name'],
|
16 |
+
config['cookie']['key'],
|
17 |
+
config['cookie']['expiry_days'],
|
18 |
+
config['preauthorized']
|
19 |
)
|
20 |
|
21 |
+
name, authentication_status, username = authenticator.login('Login', 'main')
|
|
|
22 |
|
23 |
if authentication_status:
|
24 |
+
st.write(f'Welcome *{name}*')
|
25 |
+
authenticator.logout('Logout', 'main')
|
26 |
+
|
27 |
+
# --- Text Input and Response ---
|
28 |
+
user_text = st.text_input("Enter some text:")
|
29 |
+
if user_text:
|
30 |
+
st.write("Hi!")
|
31 |
+
|
32 |
elif authentication_status == False:
|
33 |
+
st.error('Username/password is incorrect')
|
34 |
elif authentication_status == None:
|
35 |
+
st.warning('Please enter your username and password')
|