-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
405 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"database": "medicai", | ||
"user": "Pineda", | ||
"password": "Maurelys.1226#", | ||
"host": "137.184.154.249", | ||
"port": "5432" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
PuTTY-User-Key-File-2: ssh-rsa | ||
Encryption: aes256-cbc | ||
Comment: rsa-key-20230802 | ||
Public-Lines: 6 | ||
AAAAB3NzaC1yc2EAAAABJQAAAQEAgiloAPDZCuAPtjteGev6DDDBj/4f8Uf+tRdd | ||
EZvTC4f2He1/OB7Cie/8NzuBwm8BmpO+BRY/Nq3d8uqp0GNBKH4JfkqmmtCQl0Jr | ||
LI7NWnM2PUmQ5GdgE6AxSyWyE0SFgVOjTYciM7T3RmI9tCAu6plHuN4Y/CAYqq81 | ||
eXKDmXtZtgpYyRURkXbSB1lGaxmLP8/n2CTPvefn70BidcFRGKl3Yj73IQ6wTI9h | ||
m3KRhyBlSTfJryAtSiW5ZXugbHwQktKICkA82UDgI0WUBQL5U1HquxEV16y/FF4g | ||
RgZfNPWX+QcAYYYJS0KbxbPVUV3M0Ht63ez46Gjmt9oT0mDpbQ== | ||
Private-Lines: 14 | ||
vCbak9ayNOHprPYofE+HSwBCRjlD+EnzdYMJttyKkjhJtP1lV2Hykln+WHCuAyQO | ||
Rf/XaJnj9xL1zDPIcyMYLmPVKW3/HZ8vc0qN01ccPDKQ7CzUKHGBGKJNpM/+yOLM | ||
eDVrxV1wkqDdpasA7vubkrDLTu9YFS6d/z25duSKypf592gCQU6QnG+iPk/aDn2u | ||
4FDrm6EANiXtz9b2to+Vqt2HtjzX2mp+VWbcaZuydSRxKuq+KexVe+FV8oj63Ngw | ||
JOQ+UN0vdEA9LbzlYXq8zNbOglMY+vBjeQ1LV3tFDaYYzkx1sNzM68/AY62CYSqV | ||
6gEPUD5Iru2H2YcJMJ3GQXA1dqmtbNNDvfXUVBDBhq3WW1GdhGU2fsCO1CAY2QmC | ||
DEe28XQDx7xPt3S2HhMIMg8MtAMPjpLh0hrBAW5Av0+GYZd1afi77RazdmiSLqw5 | ||
Rt5v4yDJH5QoQBBRXYoTl5LwkbyZgAxI5ufsILJ3Zw4YYHAFExsK/N81WSR73aRW | ||
KyA4ySBZK4WYLSJZw61Q97aVgjcEX1fi3dBM4cn5L8Ly5Rug+nHQbpKi76UxtXYV | ||
74nmb6o+TtCvdg8GTD44kqU5ju7GXvwOZGr7KrvaaKJg64TVoFZujxRBU9vepqct | ||
W5V7PQr8fwkjDHZsEEtYEHm4dNWmFAynCJ58G738km4etmxtjjXYDA9cr/rBw4zd | ||
iOsCC8/p31YmdeFYfKwM+SkgKWAU0tGNjsKD/la/FS8dPrc3fzvcG2bne6TDhj39 | ||
nvFFCjID47OrVMCroVwsUaUiXvVFV2nZA44fxMmS1O/XmW5BYIwrF8FwDTIWAuBC | ||
5jS244kUvf0MUUFRpXUyH4aHryDB3Uij7585sXcNU84UEzko9OBCmoKPs/gUttbk | ||
Private-MAC: 0edaf22ee50fafcc3771d6b65e13645f38925fa0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#Maneja la conexión a base de datos de todo el proyecto | ||
|
||
import psycopg2 | ||
import json | ||
|
||
# #***********************************************************************************************************************Update database | ||
def database_connection(): | ||
config_path = "config.json" | ||
# Leer los datos de conexión desde el archivo JSON | ||
with open(config_path) as file: | ||
data = json.load(file) | ||
|
||
# Obtener los valores de conexión | ||
database = data['database'] | ||
user = data['user'] | ||
password = data['password'] | ||
host = data['host'] | ||
port = data['port'] | ||
|
||
# Establecer la conexión a la base de datos | ||
conn = psycopg2.connect( | ||
database=database, | ||
user=user, | ||
password=password, | ||
host=host, | ||
port=port | ||
) | ||
return conn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import pickle | ||
from pathlib import Path | ||
import streamlit_authenticator as stauth | ||
|
||
|
||
#Users | ||
names = ["Merlin Pineda", "Maurelys Jaquez"] | ||
usernames = ["Pineda","Mau"] | ||
passwords = ["abc123", "def456"] | ||
|
||
#Hashed | ||
|
||
hashed_passwords = stauth.Hasher(passwords).generate() | ||
|
||
file_path = Path(__file__).parent / "hashed_pw.pkl" | ||
with file_path.open("wb") as file: | ||
pickle.dump(hashed_passwords, file) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import pickle | ||
from pathlib import Path | ||
import streamlit_authenticator as stauth | ||
import streamlit as st | ||
import psycopg2 | ||
|
||
#---------- USER AUTHENTICATION | ||
|
||
#Users | ||
names = ["Merlin Pineda", "Maurelys Jaquez"] | ||
usernames = ["Pineda","Mau"] | ||
|
||
file_path = Path(__file__).parent / "hashed_pw.pkl" | ||
with file_path.open("rb") as file: | ||
hashed_passwords = pickle.load(file) | ||
|
||
authenticator = stauth.Authenticate(names, usernames, hashed_passwords, "sales_dashboard", "abcdef") | ||
authenticator.logout("Logout", "sidebar") | ||
name, authentication_status, username = authenticator.login("Login", "main") | ||
|
||
#Verifico authentication | ||
if authentication_status == False: | ||
st.error("Username/password is incorrect") | ||
if authentication_status == None: | ||
st.error("please enter your Username andpassword") | ||
if authentication_status: | ||
# Función para validar el inicio de sesión | ||
conn = psycopg2.connect( | ||
user="admin", | ||
password="admin", | ||
host="localhost", | ||
port="5432", # Replace with the actual port number | ||
database="medicai" | ||
) | ||
|
||
cursor = conn.cursor() | ||
|
||
# Ejecutar una consulta SELECT | ||
query = "SELECT * FROM user" | ||
cursor.execute(query) | ||
|
||
# Obtener los resultados de la consulta | ||
results = cursor.fetchall() | ||
for row in results: | ||
print(row) | ||
|
||
# Confirmar la transacción y cerrar la conexión | ||
conn.commit() | ||
conn.close() | ||
|
||
def iniciar_sesion(correo, contrasena): | ||
# Aquí puedes implementar tu lógica de validación de inicio de sesión | ||
# Por simplicidad, este código solo verifica que se ingresen datos en ambos campos | ||
if correo and contrasena: | ||
return True | ||
else: | ||
return False | ||
|
||
# Página de inicio de sesión | ||
def pagina_inicio_sesion(): | ||
st.title('Inicio de Sesión') | ||
st.write('Por favor, ingresa tus credenciales para iniciar sesión.') | ||
|
||
# Obtener los datos del usuario | ||
correo = st.text_input('Correo o usuario') | ||
contrasena = st.text_input('Contraseña', type='password') | ||
|
||
# Botón de inicio de sesión | ||
if st.button('Iniciar sesión'): | ||
if iniciar_sesion(correo, contrasena): | ||
st.success('Inicio de sesión exitoso.') | ||
else: | ||
st.error('Usuario o contraseña inválidos.') | ||
|
||
# Enlace para restablecer contraseña | ||
st.write('¿Olvidaste tu contraseña?') | ||
if st.button('Restablecer contraseña'): | ||
# Aquí puedes implementar la lógica para enviar un código de restablecimiento de contraseña al correo del usuario | ||
st.info('Se ha enviado un código de restablecimiento de contraseña a tu correo electrónico.') | ||
|
||
# Página de registro | ||
def pagina_registro(): | ||
st.title('Registro') | ||
st.write('Por favor, completa los siguientes campos para crear una cuenta.') | ||
|
||
# Obtener los datos del usuario | ||
nombre = st.text_input('Nombre') | ||
correo = st.text_input('Correo electrónico') | ||
contrasena = st.text_input('Contraseña', type='password') | ||
|
||
# Botón de registro | ||
if st.button('Crear cuenta'): | ||
# Aquí puedes implementar la lógica de registro de usuario | ||
st.success('Cuenta creada exitosamente.') | ||
|
||
# Página principal | ||
def pagina_principal(): | ||
st.title('Sistema de Registro y Gestión') | ||
|
||
# Opciones del menú | ||
opcion = st.radio('Opción', ['Inicio de Sesión', 'Registro']) | ||
|
||
# Procesar la opción seleccionada | ||
if opcion == 'Inicio de Sesión': | ||
pagina_inicio_sesion() | ||
elif opcion == 'Registro': | ||
pagina_registro() | ||
|
||
# Ejecutar la aplicación | ||
if __name__ == '__main__': | ||
pagina_principal() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
PuTTY-User-Key-File-2: ssh-rsa | ||
Encryption: aes256-cbc | ||
Comment: rsa-key-20230609 | ||
Public-Lines: 6 | ||
AAAAB3NzaC1yc2EAAAABJQAAAQEAkfQ37oNB7gRzg3ty64r0xoeHJ6pUswmWs1Et | ||
oMCfgFAwvaWwFbqIinu4SePaLXSgsUAh7jpBgb4qGL436nGimDwscSDOcoxAwcpG | ||
ATXRFUMxBKUZZVbGtgZoxNeP1yVFW13nsndrCAGN4UxsVprMIWGHB81C1KH+9lHt | ||
r5R/4AfOMtwI1t25WgbMonbg/21ypAUooNWCcBSgppW0nP4yexfMlO0+cvzcbVaH | ||
54k5oT66fcuXiv2tc/vrKfu6/a25FGnOiiq4Uzff+FqqhWhO1vCa+K6s5r6i7GyJ | ||
02dcaPl23/4wMpd0NL8LrDcZMLpB/2nWpxlK9KZfIysyWXhH4Q== | ||
Private-Lines: 14 | ||
GMtxH37KlIov63jjJ7WIiPGrhth0VV2kN5i1W5V9PpB4EkGrbPQxwcH2viq5xQZc | ||
xDD4Ci//F43wdaT6NThaCHSr2QjlCftNQu2TEEh0wjOFgZrmFEodvzmRUESHu1rn | ||
AqqAbMDjCXb2hj0SUG8ouKbVTfF/8h/Q2MR0TVCEwFXbCHBsW4FO3voL3TcBy7Dr | ||
J6x8Hcy63fVY5nOM5zOsP+q0f/XppqPobWddA8c+Jh/WimMuWtTKENjZkGfgO6Sk | ||
ucNsnL1ewx2b7lakYQV97tcs2nxH0Uv54l9WTjbYWVuNHrEH8g5UwxxrVjsQ6V/K | ||
FRx0f94JRL/ua5Ypk0zHi2QPy4eIZKyvkc8VLxWCkyPxY77QOB+1MgnVrln9p5AV | ||
DqHBiQER+fO7UZTgpNnmLrs3jg60s5pJQGGXpL0HQeNOXhfILtWGNvN42RjWb17q | ||
bkKMwTXtvdDnUQZ9bQGQE4UnaudGNB/NffL0b7B5uf1mm4mmDYkMq23nzp6MBn7w | ||
fMPZpZvXSXc3figvCLFf3A6vrNUPFnKm4lDQU4d1lVSw8Xxv2F3LfwIYKHoZksOG | ||
7F8jSoMa7uNsEgNqurAGcuM4NoRbfk08laEKY0Htg4mRNCk7LtVfJsr7ivXEqVJV | ||
J6LBzMbuHQ4CWqBL6LY9vF4boup4F56Q6ViizKZ+CYDfuC4WzX8QmS3La3YaeJqc | ||
FzMMcTIkGh0GuATvVFf18nnp33znow+tMztEAhTu2BSGTJkGHephKMgd20b6/WJW | ||
EsV4GiBRMDywnp+ong9xia4wjaeqRZ+1/ht5Mg8YLJJPriN/tTZ8ccl22gXby5rp | ||
+fjEJkCDDjdENocuvPbYYicyNrt/9hCuMWqbE504W74nnOjR+Mig4y+IFNVIm5Q9 | ||
Private-MAC: 46755dedaf466779265ad32384261fdb0ad64599 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#Pagina de Login | ||
#Permite iniciar sesion con correo o usuario y con contraseña, en caso que no sea valido usuario o contraseña debe indicarlo, debe tener un boton de incio sesion | ||
#Permite dar click en olvide contraseña para que se le envie un codigo al correo reestableciendo su contrasena | ||
#Permite dar click en boton de registrarse para crear cuenta con datos personales, correo y contraseña | ||
|
||
|
||
import streamlit as st | ||
|
||
# Función para validar el inicio de sesión | ||
def iniciar_sesion(correo, contrasena): | ||
# Aquí puedes implementar tu lógica de validación de inicio de sesión | ||
# Por simplicidad, este código solo verifica que se ingresen datos en ambos campos | ||
if correo and contrasena: | ||
return True | ||
else: | ||
return False | ||
|
||
# Página de inicio de sesión | ||
def pagina_inicio_sesion(): | ||
st.title('Inicio de Sesión') | ||
st.write('Por favor, ingresa tus credenciales para iniciar sesión.') | ||
|
||
# Obtener los datos del usuario | ||
correo = st.text_input('Correo o usuario') | ||
contrasena = st.text_input('Contraseña', type='password') | ||
|
||
# Botón de inicio de sesión | ||
if st.button('Iniciar sesión'): | ||
if iniciar_sesion(correo, contrasena): | ||
st.success('Inicio de sesión exitoso.') | ||
else: | ||
st.error('Usuario o contraseña inválidos.') | ||
|
||
# Enlace para restablecer contraseña | ||
st.write('¿Olvidaste tu contraseña?') | ||
if st.button('Restablecer contraseña'): | ||
# Aquí puedes implementar la lógica para enviar un código de restablecimiento de contraseña al correo del usuario | ||
st.info('Se ha enviado un código de restablecimiento de contraseña a tu correo electrónico.') | ||
|
||
# Página de registro | ||
def pagina_registro(): | ||
st.title('Registro') | ||
st.write('Por favor, completa los siguientes campos para crear una cuenta.') | ||
|
||
# Obtener los datos del usuario | ||
nombre = st.text_input('Nombre') | ||
correo = st.text_input('Correo electrónico') | ||
contrasena = st.text_input('Contraseña', type='password') | ||
|
||
# Botón de registro | ||
if st.button('Crear cuenta'): | ||
# Aquí puedes implementar la lógica de registro de usuario | ||
st.success('Cuenta creada exitosamente.') | ||
|
||
# Página principal | ||
def pagina_principal(): | ||
st.title('Sistema de Registro y Gestión') | ||
|
||
# Opciones del menú | ||
opcion = st.radio('Opción', ['Inicio de Sesión', 'Registro']) | ||
|
||
# Procesar la opción seleccionada | ||
if opcion == 'Inicio de Sesión': | ||
pagina_inicio_sesion() | ||
elif opcion == 'Registro': | ||
pagina_registro() | ||
|
||
# Ejecutar la aplicación | ||
if __name__ == '__main__': | ||
pagina_principal() |
Oops, something went wrong.