I'm using paho-MQTT and I'm able to receive messages. When I receive a message, I want to display the data in a template, but am unable to do so. Below is the code I have.
import paho.mqtt.client as mqtt
import json
def on_connect(client, userdata, flags, rc):
print("Connected with result code "+str(rc))
client.subscribe("mhub/hr")
def on_message(client, userdata, msg):
x = (msg.payload)
print(x)
client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.connect("mqtt.eclipseprojects.io", 1883, 60)
I have been following the tutorial.
How can I show new data from MQTT in the html template I have created?