initial checkin with access to mqtt

This commit is contained in:
2022-10-02 16:46:33 +02:00
commit 712320fb47
6 changed files with 60 additions and 0 deletions

28
app.py Normal file
View File

@@ -0,0 +1,28 @@
from flask import Flask, request
from datetime import datetime
from . import client
import re
app = Flask(__name__)
CMD = "web2mqtt/command"
@app.route("/")
def home():
return "Small URL to MQTT Gateway for home automation...!"
@app.route("/cmnd")
def command():
opts = ""
command = CMD
if request.args.get('cmnd'):
command += "/" + request.args.get('cmnd')
if request.args.get('opts'):
opts = request.args.get('opts')
client.publish(command,opts)
content = f"Command: {command} triggered with opts: {opts}"
return content