I'm currently trying to get my Python (Flask) webserver to display what my MQTT script is doing. The MQTT script, In essence, it's subscribed to a topic and I would really like to categorize the info it gets and display/update it in real time. Something like a simple list displaying various the settings that gets updated regularly.
Setting1 = 9
Setting2 = 2
Setting3 = 5
To begin with, I have a connect to page, so that you can fill-in an IP to which the Python (Flask) should connect to:
@app.route("/")
def my_form():
return render_template("connect.html")
@app.route("/", methods=["POST"])
def my_form_post():
text = request.form["text"]
processed_text = text.upper()
To which the connect.html looks like:
<!DOCTYPE html>
<html lang="en">
<body>
<h2>Fill in the IP in below:</h2>
<form action="." method="POST">
<input type="text" name="text">
<input type="submit" name="my-form" value="Connect">
</form>
</body>
</html>
The connecting to the MQTT part is where the tricky part comes in and I will require some assistance. I was thinking of just adding the connect underneath but this just doesn't work right, it will just come back with an Internal Server Error.
Any help would really be appreciated!
Thanks!