Spaces:
Running
Running
Commit ·
d4dc142
1
Parent(s): 3687fa1
Cambiar mensaje tiempo espera
Browse files- ProyectoBasura.py +2 -2
- app_front.py +4 -2
ProyectoBasura.py
CHANGED
|
@@ -118,7 +118,7 @@ def verificar_frecuencia(usuario_actual: str, segundos: int = 5):
|
|
| 118 |
segundos_restantes = segundos - int(tiempo_transcurrido.total_seconds())
|
| 119 |
raise HTTPException(
|
| 120 |
status_code=status.HTTP_429_TOO_MANY_REQUESTS,
|
| 121 |
-
detail=f"
|
| 122 |
)
|
| 123 |
registros_mensajes[usuario_actual] = ahora
|
| 124 |
|
|
@@ -181,7 +181,7 @@ async def registrar_usuario(form_data: OAuth2PasswordRequestForm = Depends(), db
|
|
| 181 |
nuevo_usuario = modelsProyecto.Usuario(
|
| 182 |
username=form_data.username,
|
| 183 |
password_hash=password_con_hash,
|
| 184 |
-
es_admin=
|
| 185 |
)
|
| 186 |
db.add(nuevo_usuario)
|
| 187 |
db.commit()
|
|
|
|
| 118 |
segundos_restantes = segundos - int(tiempo_transcurrido.total_seconds())
|
| 119 |
raise HTTPException(
|
| 120 |
status_code=status.HTTP_429_TOO_MANY_REQUESTS,
|
| 121 |
+
detail=f"Por favor, espera {segundos_restantes} segundos antes de volver a intentarlo"
|
| 122 |
)
|
| 123 |
registros_mensajes[usuario_actual] = ahora
|
| 124 |
|
|
|
|
| 181 |
nuevo_usuario = modelsProyecto.Usuario(
|
| 182 |
username=form_data.username,
|
| 183 |
password_hash=password_con_hash,
|
| 184 |
+
es_admin=False
|
| 185 |
)
|
| 186 |
db.add(nuevo_usuario)
|
| 187 |
db.commit()
|
app_front.py
CHANGED
|
@@ -70,7 +70,8 @@ def login_usuario(username, password):
|
|
| 70 |
token = res.json().get("access_token")
|
| 71 |
user_txt = f" **Usuario:** {username}"
|
| 72 |
return token, f" Hola {username}", gr.Tabs(selected=2), user_txt, user_txt, user_txt, user_txt, gr.update(visible=False), gr.update(visible=True), " Preparado para analizar imágenes"
|
| 73 |
-
|
|
|
|
| 74 |
except Exception as e:
|
| 75 |
return None, f" Error: {str(e)}", gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update()
|
| 76 |
|
|
@@ -91,7 +92,8 @@ def analizar_foto(token, imagen):
|
|
| 91 |
msg_formateado = re.sub(r' +', ' ', msg_formateado).strip()
|
| 92 |
img_res = Image.open(io.BytesIO(res.content))
|
| 93 |
return f"## {robot_html} ReciclA Dice:\n\n{msg_formateado}\n\n**Objeto:** {det}", img_res, gr.update()
|
| 94 |
-
|
|
|
|
| 95 |
except Exception as e: return f" Error: {str(e)}", None, gr.update()
|
| 96 |
|
| 97 |
def ver_historial(token):
|
|
|
|
| 70 |
token = res.json().get("access_token")
|
| 71 |
user_txt = f" **Usuario:** {username}"
|
| 72 |
return token, f" Hola {username}", gr.Tabs(selected=2), user_txt, user_txt, user_txt, user_txt, gr.update(visible=False), gr.update(visible=True), " Preparado para analizar imágenes"
|
| 73 |
+
error_msg = res.json().get('detail', 'Error al iniciar sesión')
|
| 74 |
+
return None, f"⚠️ {error_msg}", gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update()
|
| 75 |
except Exception as e:
|
| 76 |
return None, f" Error: {str(e)}", gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update()
|
| 77 |
|
|
|
|
| 92 |
msg_formateado = re.sub(r' +', ' ', msg_formateado).strip()
|
| 93 |
img_res = Image.open(io.BytesIO(res.content))
|
| 94 |
return f"## {robot_html} ReciclA Dice:\n\n{msg_formateado}\n\n**Objeto:** {det}", img_res, gr.update()
|
| 95 |
+
error_msg = res.json().get('detail', 'Error al analizar la imagen')
|
| 96 |
+
return f"### ⚠️ Aviso\n{error_msg}", None, gr.update()
|
| 97 |
except Exception as e: return f" Error: {str(e)}", None, gr.update()
|
| 98 |
|
| 99 |
def ver_historial(token):
|