Spaces:
Runtime error
Runtime error
coder
commited on
Commit
·
fa397ad
1
Parent(s):
19de612
update no login
Browse files- core/controllers/pages_controller.py +1 -77
- pages/Aboutme.py +4 -6
- pages/LiveDemo.py +2 -3
core/controllers/pages_controller.py
CHANGED
|
@@ -51,80 +51,4 @@ class Page():
|
|
| 51 |
self.page().markdown(
|
| 52 |
f'<style>{archivo.read()}</style>', unsafe_allow_html=True)
|
| 53 |
except Exception as er:
|
| 54 |
-
print(f"Error:\n{er}")
|
| 55 |
-
|
| 56 |
-
def check_password(self):
|
| 57 |
-
if self.user_logged_in():
|
| 58 |
-
self.page().sidebar.success("👨💻 Conectado")
|
| 59 |
-
self.page().sidebar.button("Logout", use_container_width=True,
|
| 60 |
-
type="primary", on_click=self.logout)
|
| 61 |
-
return True
|
| 62 |
-
else:
|
| 63 |
-
self.page().sidebar.subheader("# ¡👨💻 Desbloquea todas las funciones!")
|
| 64 |
-
self.page().sidebar.write("¡Ingresa tu Usuario y Contraseña!")
|
| 65 |
-
self.page().sidebar.text_input("Usuario", value="",
|
| 66 |
-
on_change=self.login, key="USUARIO")
|
| 67 |
-
self.page().sidebar.text_input("Password", type="password",
|
| 68 |
-
on_change=self.login, key="PASSWORD", value="")
|
| 69 |
-
self.page().sidebar.button("LogIn", use_container_width=True, on_click=self.login)
|
| 70 |
-
return False
|
| 71 |
-
|
| 72 |
-
def user_logged_in(self):
|
| 73 |
-
return self.get_global('logged_in', False)
|
| 74 |
-
|
| 75 |
-
def login(self):
|
| 76 |
-
_usuario = str(self.get_global("USUARIO"))
|
| 77 |
-
_factor = int(self.get_global('FPSSWD',"20", True))
|
| 78 |
-
print(_factor)
|
| 79 |
-
if self.get_global(self.codificar(_usuario,_factor), None, True) is not None:
|
| 80 |
-
if self.codificar(self.get_global("PASSWORD"), _factor) == self.get_global(self.codificar(_usuario,_factor), None, True):
|
| 81 |
-
del self.page().session_state["USUARIO"]
|
| 82 |
-
del self.page().session_state["PASSWORD"]
|
| 83 |
-
self.set_global('logged_in', True)
|
| 84 |
-
else:
|
| 85 |
-
self.logout("😕 Ups! Contraseña Incorrecta")
|
| 86 |
-
else:
|
| 87 |
-
self.logout("😕 Ups! Nombre de Usuario Incorrecto")
|
| 88 |
-
|
| 89 |
-
def logout(self, mensaje=str("¡Vuelva Pronto!")):
|
| 90 |
-
self.page().sidebar.error(mensaje)
|
| 91 |
-
self.set_global('hf_key')
|
| 92 |
-
self.set_global('logged_in')
|
| 93 |
-
|
| 94 |
-
@staticmethod
|
| 95 |
-
def codificar(palabra=str(), modificador=None):
|
| 96 |
-
# Acepta:
|
| 97 |
-
# ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
| 98 |
-
# abcdefghijklmnopqrstuvwxyz
|
| 99 |
-
# 1234567890!#$-_=%&/()*[]
|
| 100 |
-
codigo = str()
|
| 101 |
-
try:
|
| 102 |
-
for _byte in bytearray(palabra.strip(), 'utf-8'):
|
| 103 |
-
# x = f(y) => la variable 'x' estará en función de la variable 'y'
|
| 104 |
-
# Si ... f(y) = y² * k => donde:
|
| 105 |
-
# x es el valor decimal del input en bytes
|
| 106 |
-
# modificador es un número real variable, definido por el usuario
|
| 107 |
-
_y = int(format(_byte, 'b'), 2)
|
| 108 |
-
_x = int(pow(_y, 2) * modificador)
|
| 109 |
-
# magia
|
| 110 |
-
codigo = f" {bin(_x)}{codigo}"
|
| 111 |
-
except Exception as error:
|
| 112 |
-
print(f"Error Codificando:\n{error}")
|
| 113 |
-
return codigo.strip()
|
| 114 |
-
|
| 115 |
-
@staticmethod
|
| 116 |
-
def decodificar(codigo=str(), modificador=None):
|
| 117 |
-
# SOLO DECODIFICA SU ECUACIÓN INVERSA...
|
| 118 |
-
palabra = str()
|
| 119 |
-
try:
|
| 120 |
-
for _byte_str in codigo.strip().split(' '):
|
| 121 |
-
# entonces...podemos decir que y = √(x/k)
|
| 122 |
-
# es su ecuación inversa correspondiente
|
| 123 |
-
_x = int(_byte_str, 2)
|
| 124 |
-
_y = int(pow((_x/modificador), 1/2))
|
| 125 |
-
letra = _y.to_bytes(_y.bit_length(), 'big').decode()
|
| 126 |
-
# magia
|
| 127 |
-
palabra = f"{letra}{palabra}"
|
| 128 |
-
except Exception as error:
|
| 129 |
-
print(f"Error Decodificando:\n{error}")
|
| 130 |
-
return palabra.stip()
|
|
|
|
| 51 |
self.page().markdown(
|
| 52 |
f'<style>{archivo.read()}</style>', unsafe_allow_html=True)
|
| 53 |
except Exception as er:
|
| 54 |
+
print(f"Error:\n{er}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages/Aboutme.py
CHANGED
|
@@ -78,12 +78,10 @@ class AboutMe(Page):
|
|
| 78 |
columna_bienvenido, columna_contenido = self.get_body().columns(2, gap="small")
|
| 79 |
seccion_teoria, seccion_live_demo = columna_contenido.columns(
|
| 80 |
2, gap="large")
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
self.agregar_card_live_demo(seccion_live_demo)
|
| 86 |
-
self.agregar_card_about_me(columna_contenido)
|
| 87 |
|
| 88 |
|
| 89 |
if __name__ == "__main__":
|
|
|
|
| 78 |
columna_bienvenido, columna_contenido = self.get_body().columns(2, gap="small")
|
| 79 |
seccion_teoria, seccion_live_demo = columna_contenido.columns(
|
| 80 |
2, gap="large")
|
| 81 |
+
self.agregar_card_bienvenido(columna_bienvenido)
|
| 82 |
+
self.agregar_card_teoria(seccion_teoria)
|
| 83 |
+
self.agregar_card_live_demo(seccion_live_demo)
|
| 84 |
+
self.agregar_card_about_me(columna_contenido)
|
|
|
|
|
|
|
| 85 |
|
| 86 |
|
| 87 |
if __name__ == "__main__":
|
pages/LiveDemo.py
CHANGED
|
@@ -135,9 +135,8 @@ class Live_Demo(Page):
|
|
| 135 |
def build(self):
|
| 136 |
# secciones
|
| 137 |
columna_inputs, columna_outputs = self.get_body().columns(2, gap="small")
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
self.agregar_card_outputs(columna_outputs)
|
| 141 |
|
| 142 |
|
| 143 |
if __name__ == "__main__":
|
|
|
|
| 135 |
def build(self):
|
| 136 |
# secciones
|
| 137 |
columna_inputs, columna_outputs = self.get_body().columns(2, gap="small")
|
| 138 |
+
self.agregar_card_inputs(columna_inputs)
|
| 139 |
+
self.agregar_card_outputs(columna_outputs)
|
|
|
|
| 140 |
|
| 141 |
|
| 142 |
if __name__ == "__main__":
|