Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vue_django_test
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
周田
vue_django_test
Commits
623cd6a0
Commit
623cd6a0
authored
Aug 28, 2023
by
周田
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mod:删除不必要的代码
parent
69fbe438
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
0 additions
and
20 deletions
+0
-20
views.py
chat/views.py
+0
-1
mqtt.py
mqtt/mqtt.py
+0
-1
signals.py
mqtt/signals.py
+0
-3
views.py
mqtt/views.py
+0
-15
No files found.
chat/views.py
deleted
100644 → 0
View file @
69fbe438
from
django.shortcuts
import
render
mqtt/mqtt.py
View file @
623cd6a0
import
paho.mqtt.client
as
mqtt
from
django.conf
import
settings
from
.utils
import
parse_proto
from
.signals
import
mqtt_message_received
# *******************************************************
...
...
mqtt/signals.py
deleted
100644 → 0
View file @
69fbe438
import
django.dispatch
mqtt_message_received
=
django
.
dispatch
.
Signal
(
providing_args
=
[
'message'
])
mqtt/views.py
View file @
623cd6a0
...
...
@@ -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'
]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment