|
import streamlit as st |
|
from streamlit.logger import get_logger |
|
import streamlit_authenticator as stauth |
|
import yaml |
|
|
|
LOGGER = get_logger(__name__) |
|
|
|
def run(): |
|
st.set_page_config( |
|
page_title="SKT AI Fellowship Team ASAP", |
|
page_icon="π‘", |
|
layout="centered" |
|
) |
|
|
|
st.write("# SKT AI Fellowship Team ASAP π") |
|
|
|
def st_authenticator(): |
|
with open('config.yaml') as file: |
|
config = yaml.load(file, Loader=stauth.SafeLoader) |
|
|
|
authenticator = stauth.Authenticate( |
|
config['credentials'], |
|
config['cookie']['name'], |
|
config['cookie']['key'], |
|
config['cookie']['expiry_days'], |
|
config['preauthorized'] |
|
) |
|
|
|
return authenticator |
|
|
|
if __name__ == "__main__": |
|
run() |
|
authenticator = st_authenticator() |
|
|
|
if 'authentication_status' not in st.session_state: |
|
st.session_state['authentication_status'] = None |
|
st.session_state['username'] = None |
|
|
|
name, authentication_status, username = authenticator.login("main", "Login") |
|
|
|
if authentication_status: |
|
st.session_state['authentication_status'] = True |
|
st.session_state['username'] = username |
|
st.success(f"{name}λ, νμν©λλ€!") |
|
authenticator.logout('Logout', 'main', key='unique_key') |
|
|
|
elif authentication_status is False: |
|
st.session_state['authentication_status'] = False |
|
st.error('μμ΄λ/λΉλ°λ²νΈκ° μλͺ»λμμ΅λλ€.') |
|
|
|
elif authentication_status is None: |
|
st.session_state['authentication_status'] = None |
|
st.warning('μμ΄λμ λΉλ°λ²νΈλ₯Ό μ
λ ₯ν΄μ£ΌμΈμ.') |
|
|
|
|