Commit f77e6035 authored by Peter-Bernd Otte's avatar Peter-Bernd Otte

Changed HTTP Headers and more MQTT debug msgs

parent 12b66cb3
......@@ -57,8 +57,8 @@ client= paho.Client(args.mqtt_client_name)
client.on_message=on_message
client.on_connect = on_connect
client.on_disconnect = on_disconnect
logger.debug("connecting to broker "+args.mqtt_broker_host)
client.enable_logger(logger)
logger.info("connecting to broker "+args.mqtt_broker_host)
client.connect(args.mqtt_broker_host)
client.loop_start() #start loop to process received messages in separate thread
logger.info ("MQTT Loop started.")
......@@ -68,7 +68,7 @@ class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header("Content-type", "text/json;charset=UTF-8")
self.send_header("Access-Control-Allow-Origin", "<origin> | *")
self.send_header("Access-Control-Allow-Origin", "*")
self.end_headers()
# self.path equals GET Parameter: "/foo/bar/".
erg = parse.parse("/{topic}/set?{value:d}", self.path)
......@@ -76,7 +76,7 @@ class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
#print(erg)
topic = unquote(erg['topic']) if erg else None
if erg and topic in mlast:
print("topic:",topic)
#print("topic:",topic)
if 'value' in erg:
logger.info("publish: "+str(topic)+" value: "+str(erg['value']) )
client.publish(topic+"/set", erg['value'], qos=1, retain=False) # send command to Relais
......@@ -96,4 +96,4 @@ except KeyboardInterrupt:
logger.info ('^C received, shutting down the web server')
httpd.server_close()
client.disconnect()
client.loop_stop()
\ No newline at end of file
client.loop_stop()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment