Modifying file
This commit is contained in:
parent
c72f027362
commit
86441e051d
2 changed files with 19 additions and 11 deletions
|
@ -39,7 +39,7 @@ void handleNotFound()
|
||||||
void closeCircuitViaWifi()
|
void closeCircuitViaWifi()
|
||||||
{
|
{
|
||||||
closeCircuitAndOpen();
|
closeCircuitAndOpen();
|
||||||
server.send(200, "text/plain","Done");
|
server.send(200, "text/plain","Done\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
|
|
24
myapp.py
24
myapp.py
|
@ -6,8 +6,7 @@ app = flask.Flask(import_name=__name__)
|
||||||
|
|
||||||
@app.route(rule="/")
|
@app.route(rule="/")
|
||||||
def index():
|
def index():
|
||||||
print("Can print inside the called function")
|
return "200 OK (working)\n"
|
||||||
return "Okay, got it !"
|
|
||||||
|
|
||||||
lock = threading.Lock()
|
lock = threading.Lock()
|
||||||
def opener(lck):
|
def opener(lck):
|
||||||
|
@ -17,15 +16,24 @@ def opener(lck):
|
||||||
|
|
||||||
@app.route(rule="/receiving", methods=["POST"])
|
@app.route(rule="/receiving", methods=["POST"])
|
||||||
def receiver():
|
def receiver():
|
||||||
#data = flask.request.get_json()
|
|
||||||
#for field in data: print(field, ":", data[field])
|
|
||||||
data = flask.request.get_data(as_text=True)
|
data = flask.request.get_data(as_text=True)
|
||||||
print(data)
|
parts = data.split("&")
|
||||||
print(flask.request.args)
|
data_dict = {}
|
||||||
if "please" in data:
|
for part in parts:
|
||||||
|
parameter_name, parameter_value = part.split("=")
|
||||||
|
data_dict[parameter_name] = parameter_value
|
||||||
|
print(data_dict)
|
||||||
|
#---action=incoming / message_type=sms---
|
||||||
|
if data_dict["action"]=="incoming":
|
||||||
|
if "please" in data_dict["message"].lower():
|
||||||
op = threading.Thread(target=opener, args=(lock,))
|
op = threading.Thread(target=opener, args=(lock,))
|
||||||
op.start()
|
op.start()
|
||||||
return flask.jsonify({"events":[{"event":"log","message":"server received sms successfully"}]})
|
return flask.jsonify({"events":[{"event":"log","message":"Server received "+data_dict["message_type"]+" from "+data_dict["from"]}]})
|
||||||
|
#---action=incoming---
|
||||||
|
#---action=incoming---
|
||||||
|
#---action=incoming---
|
||||||
|
#---action=incoming---
|
||||||
|
#---action=incoming---
|
||||||
|
|
||||||
if __name__=="__main__":
|
if __name__=="__main__":
|
||||||
app.run(host="0.0.0.0", debug=True)
|
app.run(host="0.0.0.0", debug=True)
|
||||||
|
|
Loading…
Reference in a new issue