From 7c7b85131c450a26be6f258a88dcfd7b5a1bbda3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zulma=20Casta=C3=B1eda?= Date: Tue, 8 May 2018 10:02:37 -0500 Subject: [PATCH] REST que camilo no hizo Es broma, yo le dije que no lo hiciera :v --- EntidadVirtual/API_REST/test_cerradura.py | 43 +++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 EntidadVirtual/API_REST/test_cerradura.py diff --git a/EntidadVirtual/API_REST/test_cerradura.py b/EntidadVirtual/API_REST/test_cerradura.py new file mode 100644 index 0000000..2243e72 --- /dev/null +++ b/EntidadVirtual/API_REST/test_cerradura.py @@ -0,0 +1,43 @@ +from flask import Flask +import time +import paho.mqtt.client as paho +app = Flask(__name__) +broker="broker.hivemq.com" + + +#Insertar una cerradura +@app.route("/cerradura", methods=["POST"]) +def insert_cerradura(): + password = request.json['password'] + posicion = request.json['posicion'] + hora_inicio = request.json['hora_inicio'] + hora_fin = request.json['hora_fin'] + + nuevo_candado = "0;"+password+";"+posicion; + #Escribir y publicar mensaje + + +@app.route("/cerradura", methods=["UPDATE"]) +def update_cerradura(): + password = request.json['password'] + posicion = request.json['posicion'] + nuevo_candado = "1;"+password+";"+posicion; + + +@app.route("/cerradura", methods=["DELETE"]) +def delete_cerradura(): + posicion = request.json['posicion'] + nuevo_candado = "2;" + posicion; + +@app.route("/cerradura_all", methods=["DELETE"]) +def delete_all_cerraduras(): + mensaje = "3" + + +@app.route("/cerradura", methods = ["PUT"]) +def change_state_cerradura(): + posicion = request.json['posicion'] + mensaje = "4;"posicion; + +if __name__ == '__main__': + app.run(debug=True)