-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmateriales.py
More file actions
27 lines (24 loc) · 741 Bytes
/
materiales.py
File metadata and controls
27 lines (24 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from flask import jsonify, Blueprint, request, abort
#from app.db import connection
import json
from models.material import Material
from flask_cors import CORS, cross_origin
materiales_api = Blueprint("materiales", __name__, url_prefix="/materiales")
@materiales_api.get("/")
@cross_origin()
def index():
lista = Material.buscar("",0)
aux =[]
i = 0;
if lista:
while i < len(lista):
print(type(lista[i]))
variable = lista[i]
aux.append({"Nombre": variable.nombre,"Costo": variable.costo,"Cantidad": variable.cantidad,"Empresa": variable.empresa,"Id": variable.id})
i = i + 1
x = {
"materiales": [
aux
]
}
return jsonify(x)