import streamlit as st import streamlit_authenticator as stauth import yaml from yaml.loader import SafeLoader import main with open('credentials.yaml') as file: config = yaml.load(file, Loader=SafeLoader) authenticator = stauth.Authenticate( config['credentials'], config['cookie']['name'], config['cookie']['key'], config['cookie']['expiry_days'], config['preauthorized'] ) name, authentication_status, username = authenticator.login('Logga in', 'main') if authentication_status: # Say hello st.write(f'**Hej {name}!**') # Ask for input user_input = str(st.text_input('Skriv in telefonnummer eller Facebook-ID', )).strip() if user_input != '': s = [] for i in user_input: if i.isnumeric(): s.append(str(i)) s = ''.join(s) if s[0] == '0': s = '46' + s[1:] # Search for info. r = main.search(s) if r != None: if r['column_find'] == 'ID': id = r['find'] r['find'] = f'{id}' st.write(f"{r['name']}, {r['column_find']}: {r['find']}", unsafe_allow_html=True) with st.expander('Mer information'): st.dataframe(r['df'], use_container_width=True) else: st.text('Not found.') elif authentication_status is False: st.error('Fel användarnamn/lösenord') elif authentication_status is None: st.warning('Skriv in användarnamn och lösenord')