|
|
|
|
@ -5,17 +5,8 @@ from yaml.loader import SafeLoader |
|
|
|
|
import main |
|
|
|
|
import create_credentials |
|
|
|
|
import traceback |
|
|
|
|
from time import sleep |
|
|
|
|
|
|
|
|
|
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'] |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
def add_user(): |
|
|
|
|
st.write(':red[Skapa ny användare]') |
|
|
|
|
@ -32,7 +23,43 @@ def add_user(): |
|
|
|
|
else: |
|
|
|
|
st.write('Användare finns redan.') |
|
|
|
|
|
|
|
|
|
def search(user_input): |
|
|
|
|
s = [] |
|
|
|
|
for i in user_input: |
|
|
|
|
if i.isnumeric(): |
|
|
|
|
s.append(str(i)) |
|
|
|
|
s = ''.join(s) |
|
|
|
|
|
|
|
|
|
if s[0:2] == '07' and len(s) == 10: |
|
|
|
|
s = '46' + s[1:] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Search for info. |
|
|
|
|
r = main.search(s) |
|
|
|
|
|
|
|
|
|
# Present result. |
|
|
|
|
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('Hittade inga uppgifter.') |
|
|
|
|
|
|
|
|
|
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') |
|
|
|
|
|
|
|
|
|
@ -44,36 +71,20 @@ if authentication_status: |
|
|
|
|
if username == 'admin': |
|
|
|
|
add_user() |
|
|
|
|
|
|
|
|
|
# Ask for input |
|
|
|
|
# Ask for input |
|
|
|
|
help_text = '[Du kan hitta en profils Facebook-ID här](https://findidfb.com/)' |
|
|
|
|
user_input = str(st.text_input('Skriv in telefonnummer eller Facebook-ID', help=help_text, placeholder='Skriv här...')).strip() |
|
|
|
|
|
|
|
|
|
if user_input != '': |
|
|
|
|
s = [] |
|
|
|
|
for i in user_input: |
|
|
|
|
if i.isnumeric(): |
|
|
|
|
s.append(str(i)) |
|
|
|
|
s = ''.join(s) |
|
|
|
|
|
|
|
|
|
if s[0:2] == '07' and len(s) == 10: |
|
|
|
|
s = '46' + s[1:] |
|
|
|
|
search_button = st.button('Sök') |
|
|
|
|
if search_button and user_input != '': |
|
|
|
|
sleep(0.1) |
|
|
|
|
r = search(user_input) |
|
|
|
|
|
|
|
|
|
# Search for info. |
|
|
|
|
r = main.search(s) |
|
|
|
|
|
|
|
|
|
# Present result. |
|
|
|
|
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('Hittade inga uppgifter.') |
|
|
|
|
more = st.expander('Övrigt', ) |
|
|
|
|
|
|
|
|
|
authenticator.logout('Logout', 'main') |
|
|
|
|
with more: |
|
|
|
|
st.write('Byggd av Lasse Edfast. Används endast för journalistiskt syfte och med tillstånd.') |
|
|
|
|
authenticator.logout('Logout', 'main') |
|
|
|
|
except Exception as e: |
|
|
|
|
traceback.print_exc() |
|
|
|
|
st.write('Något gick fel :(') |
|
|
|
|
|