You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.5 KiB
53 lines
1.5 KiB
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: |
|
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'<a href="http://facebook.com/{id}">{id}</a>' |
|
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.') |
|
st.markdown(':red[Vid frågor mejla lasse@edfast.se]') |
|
|
|
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') |
|
|
|
|
|
|