Commit 623cd6a0 by 周田

mod:删除不必要的代码

parent 69fbe438
from django.shortcuts import render
import paho.mqtt.client as mqtt
from django.conf import settings
from .utils import parse_proto
from .signals import mqtt_message_received
# *******************************************************
......
import django.dispatch
mqtt_message_received = django.dispatch.Signal(providing_args=['message'])
......@@ -4,9 +4,7 @@ from django.shortcuts import render, redirect
from django.dispatch import receiver
from mqtt.mqtt import client as mqtt_client
from mqtt.signals import mqtt_message_received
MESSAGE = b""
def publish_message(request):
# request_data = json.loads(request.body)
......@@ -14,16 +12,3 @@ def publish_message(request):
msg = request.POST['msg']
rc, mid = mqtt_client.publish(topic, msg)
return JsonResponse({'code': rc})
def index(request):
global MESSAGE
token = get_token(request)
return render(request, 'index.html', {'token': token, 'msg': MESSAGE.decode('utf-8')})
@receiver(mqtt_message_received)
def show_message(sender, **kwargs):
global MESSAGE
print('Received message:', kwargs['message'])
MESSAGE = kwargs['message']
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