set up docker generation
This commit is contained in:
45
web2mqtt/views.py
Normal file
45
web2mqtt/views.py
Normal 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
|
||||
Reference in New Issue
Block a user