initial checkin with access to mqtt
This commit is contained in:
28
app.py
Normal file
28
app.py
Normal 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
|
||||
Reference in New Issue
Block a user