Skip to content

Commit

Permalink
REST que camilo no hizo
Browse files Browse the repository at this point in the history
Es broma, yo le dije que no lo hiciera :v
  • Loading branch information
zlcastaneda10 committed May 8, 2018
1 parent 3700fd8 commit 7c7b851
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions EntidadVirtual/API_REST/test_cerradura.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 7c7b851

Please sign in to comment.