Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI, Request
|
| 2 |
+
from pydantic import BaseModel
|
| 3 |
+
from typing import List
|
| 4 |
+
import uvicorn
|
| 5 |
+
|
| 6 |
+
app = FastAPI()
|
| 7 |
+
|
| 8 |
+
class Input(BaseModel):
|
| 9 |
+
inputs: str
|
| 10 |
+
|
| 11 |
+
@app.post("/")
|
| 12 |
+
async def predict(data: Input):
|
| 13 |
+
try:
|
| 14 |
+
ventas = list(map(float, data.inputs.split(',')))
|
| 15 |
+
if len(ventas) < 2:
|
| 16 |
+
return {"result": "Datos insuficientes"}
|
| 17 |
+
return {"result": "Bien" if ventas[-1] > ventas[-2] else "Mal"}
|
| 18 |
+
except:
|
| 19 |
+
return {"result": "Error en datos"}
|