-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Es broma, yo le dije que no lo hiciera :v
- Loading branch information
1 parent
3700fd8
commit 7c7b851
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |