set up docker generation

This commit is contained in:
2022-10-02 17:43:55 +02:00
parent 712320fb47
commit 0b66d4ae0d
21 changed files with 447 additions and 58 deletions

45
web2mqtt/views.py Normal file
View File

@@ -0,0 +1,45 @@
from datetime import datetime
from flask import Flask, render_template,request
from . import app, client
@app.route("/")
def home():
return render_template("home.html")
@app.route("/about/")
def about():
return render_template("about.html")
@app.route("/contact/")
def contact():
return render_template("contact.html")
@app.route("/hello/")
@app.route("/hello/<name>")
def hello_there(name = None):
return render_template(
"hello_there.html",
name=name,
date=datetime.now()
)
@app.route("/api/data")
def get_data():
return app.send_static_file("data.json")
CMD = "web2mqtt/command"
@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