Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,34 +1,30 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import json
|
| 3 |
|
| 4 |
-
def
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
resultado = "Bien" if total_ultimo > total_penultimo else "Mal"
|
| 22 |
-
|
| 23 |
-
return json.dumps({"result": resultado})
|
| 24 |
-
|
| 25 |
-
except Exception as e:
|
| 26 |
-
return json.dumps({"error": str(e)})
|
| 27 |
|
| 28 |
iface = gr.Interface(
|
| 29 |
-
fn=
|
| 30 |
-
inputs=gr.Textbox(lines=10, placeholder=
|
| 31 |
-
outputs="text"
|
|
|
|
|
|
|
| 32 |
)
|
| 33 |
|
| 34 |
-
|
|
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
+
def analizar_ventas(ventas_texto):
|
| 4 |
+
lineas = ventas_texto.strip().split("\n")
|
| 5 |
+
total = 0
|
| 6 |
+
for linea in lineas:
|
| 7 |
+
try:
|
| 8 |
+
partes = linea.split("-")
|
| 9 |
+
precio_x_cantidad = partes[1].strip()
|
| 10 |
+
precio, num_pares = precio_x_cantidad.split("x")
|
| 11 |
+
precio = float(precio.strip())
|
| 12 |
+
num_pares = int(num_pares.strip())
|
| 13 |
+
total += precio * num_pares
|
| 14 |
+
except:
|
| 15 |
+
pass
|
| 16 |
+
if total > 1000:
|
| 17 |
+
return "Bien"
|
| 18 |
+
else:
|
| 19 |
+
return "Mal"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
iface = gr.Interface(
|
| 22 |
+
fn=analizar_ventas,
|
| 23 |
+
inputs=gr.Textbox(lines=10, placeholder="Marca Talla - Precio x NumPares\nEjemplo:\nNike 38 - 150 x 2"),
|
| 24 |
+
outputs="text",
|
| 25 |
+
title="Análisis de crecimiento de ventas",
|
| 26 |
+
description="Ingresa las ventas para saber si el crecimiento es Bien o Mal"
|
| 27 |
)
|
| 28 |
|
| 29 |
+
if __name__ == "__main__":
|
| 30 |
+
iface.launch()
|