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