Removing unnecesary elif fixing #7

Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com>
This commit is contained in:
0x6f736f646f
2020-06-25 01:23:22 +03:00
parent d8b4576533
commit dbe9da10e3
+48 -49
View File
@@ -19,64 +19,63 @@ app = Flask(__name__)
def publish():
if request.method == "GET":
return "Server is up"
elif request.method == "POST":
global client
command = request.get_json()['queryResult']['queryText']
if command.__contains__("on"):
client.publish(topic=mqtt_topic, payload="ON", qos=0, retain=True)
return {
"payload": {
"google": {
"expectUserResponse": True,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "The lights are on"
}
}
]
}
global client
command = request.get_json()['queryResult']['queryText']
if command.__contains__("on"):
client.publish(topic=mqtt_topic, payload="ON", qos=0, retain=True)
return {
"payload": {
"google": {
"expectUserResponse": True,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "The lights are on"
}
}
]
}
}
}
elif command.__contains__("off"):
client.publish(topic=mqtt_topic, payload="OFF", qos=0, retain=True)
return {
"payload": {
"google": {
"expectUserResponse": True,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "The lights are off"
}
}
]
}
}
elif command.__contains__("off"):
client.publish(topic=mqtt_topic, payload="OFF", qos=0, retain=True)
return {
"payload": {
"google": {
"expectUserResponse": True,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "The lights are off"
}
}
]
}
}
}
else:
return {
"payload": {
"google": {
"expectUserResponse": True,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech":
"Do you want to turn "
"on or off the lights"
}
}
]
}
}
else:
return {
"payload": {
"google": {
"expectUserResponse": True,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech":
"Do you want to turn "
"on or off the lights"
}
}
]
}
}
}
}
if __name__ == "__main__":