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()
|
||||
{
|
||||
closeCircuitAndOpen();
|
||||
server.send(200, "text/plain","Done");
|
||||
server.send(200, "text/plain","Done\n");
|
||||
}
|
||||
|
||||
void setup()
|
||||
|
|
28
myapp.py
28
myapp.py
|
@ -6,8 +6,7 @@ app = flask.Flask(import_name=__name__)
|
|||
|
||||
@app.route(rule="/")
|
||||
def index():
|
||||
print("Can print inside the called function")
|
||||
return "Okay, got it !"
|
||||
return "200 OK (working)\n"
|
||||
|
||||
lock = threading.Lock()
|
||||
def opener(lck):
|
||||
|
@ -17,15 +16,24 @@ def opener(lck):
|
|||
|
||||
@app.route(rule="/receiving", methods=["POST"])
|
||||
def receiver():
|
||||
#data = flask.request.get_json()
|
||||
#for field in data: print(field, ":", data[field])
|
||||
data = flask.request.get_data(as_text=True)
|
||||
print(data)
|
||||
print(flask.request.args)
|
||||
if "please" in data:
|
||||
op = threading.Thread(target=opener, args=(lock,))
|
||||
op.start()
|
||||
return flask.jsonify({"events":[{"event":"log","message":"server received sms successfully"}]})
|
||||
parts = data.split("&")
|
||||
data_dict = {}
|
||||
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.start()
|
||||
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__":
|
||||
app.run(host="0.0.0.0", debug=True)
|
||||
|
|
Loading…
Reference in a new issue