-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
128 lines (97 loc) · 3.83 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
############################################################################################
# Packages #
############################################################################################
import streamlit as st
import client.setup as setup
# import base64
import plotly.express as px
############################################################################################
# Check Requirements #
############################################################################################
# Lista de funções importadas
funcoes_importadas = [
'streamlit',
'client.setup',
]
# Verifica se cada função está presente no arquivo requirements.txt
faltando = []
with open('requirements.txt') as f:
for line in f:
for funcao in funcoes_importadas:
if funcao in line:
break
else:
faltando.append(funcao)
# Imprime as funções que não estão presentes no arquivo
if faltando:
print('As seguintes funções não estão presentes no arquivo requirements.txt:')
print('\n'.join(faltando))
else:
print('Todas as funções importadas estão presentes no arquivo requirements.txt.')
############################################################################################
# Functions #
############################################################################################
def login_page():
st.title("Login")
username = st.text_input("Nome de usuário", key="username_input")
password = st.text_input("Senha", type="password", key="password_input")
st.button("Login")
if setup.authenticate_user(username, password):
st.empty()
return True
else:
if username == "" and password == "":
st.error("Por favor, insira um nome de usuário e senha.")
elif username != "" and password != "":
st.error("Nome de usuário ou senha incorretos.")
return False
############################################################################################
# Main #
############################################################################################
if __name__ == '__main__':
df = px.data.iris()
# # @st.experimental_memo
# def get_img_as_base64(file):
# with open(file, "rb") as f:
# data = f.read()
# return base64.b64encode(data).decode()
# img = get_img_as_base64("client/src/public/image.jpg")
# page_bg_img = f"""
# <style>
# [data-testid="stAppViewContainer"] > .main {{
# background-image: url("https://cdn.folhape.com.br/img/pc/1100/1/dn_arquivo/2022/11/copia-de-enquadramento-capa_2.jpg");
# background-size: 180%;
# background-position: top left;
# background-repeat: no-repeat;
# background-attachment: local;
# }}
# [data-testid="stSidebar"] > div:first-child {{
# background-image: url("data:image/png;base64,{img}");
# background-position: center;
# background-repeat: no-repeat;
# background-attachment: fixed;
# }}
# [data-testid="stHeader"] {{
# background: rgba(0,0,0,0);
# }}
# [data-testid="stToolbar"] {{
# right: 2rem;
# }}
# </style>
# """
# st.markdown(page_bg_img, unsafe_allow_html=True)
# st.title("It's summer!")
# st.sidebar.header("Configuration")
if "logged_in" not in st.session_state:
st.session_state.logged_in = False
if not st.session_state.logged_in:
logged_in = login_page()
if logged_in:
st.session_state.logged_in = True
st.experimental_rerun()
else:
st.empty()
setup.mainLogin()
if st.button("Logout"):
st.session_state.logged_in = False
st.experimental_rerun()