Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
channels
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
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
gaoming
channels
Commits
b5797ede
Commit
b5797ede
authored
Jun 13, 2019
by
gaoming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
guangdiantong
parent
934eb572
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
11 deletions
+33
-11
server_settings.py
channels/server_settings.py
+8
-2
views.py
like/views.py
+24
-7
start_celery.sh
start_celery.sh
+1
-2
No files found.
channels/server_settings.py
View file @
b5797ede
...
...
@@ -27,13 +27,19 @@ DEBUG = False
ALLOWED_HOSTS
=
[
'*'
]
#**********************************Celery Config********************************************
*****
#**********************************Celery Config********************************************
CELERY_BROKER_URL
=
'redis://:zi1jlhVHtH8MGNqB@172.17.40.145:6379/7'
# Broker配置,使用Redis作为消息中间件
CELERY_RESULT_BACKEND
=
'redis://:zi1jlhVHtH8MGNqB@172.17.40.145:6379/7'
# BACKEND配置,这里使用redis
CELERY_RESULT_SERIALIZER
=
'json'
# 结果序列化方案
#***********************************************************************************
#************************************requests***********************************************
REQUESTS_CONNECT_TIMEOUT
=
5
REQUESTS_READ_TIMEOUT
=
5
#************************************requests***********************************************
# Application definition
...
...
like/views.py
View file @
b5797ede
...
...
@@ -14,6 +14,7 @@ from django.views.decorators.csrf import csrf_exempt
from
django.http
import
HttpResponseNotAllowed
,
JsonResponse
,
HttpResponse
,
Http404
from
django.views.generic
import
View
from
.models
import
*
from
django.conf
import
settings
from
celery
import
shared_task
from
django.db.models
import
Q
...
...
@@ -60,6 +61,7 @@ class Statistic(View):
platform
=
kwargs
.
get
(
'platform'
,
''
)
#time.sleep(2)
#设备编号相关id
device_id
=
kwargs
.
get
(
'device_id'
)
...
...
@@ -113,11 +115,11 @@ class Statistic(View):
#GET回调
if
record
.
callback_type
==
CHANNEL_CALLBACK_TYPE
.
GET_CALLBACK
.
value
[
0
]:
print
(
url
)
response
=
requests
.
get
(
url
)
response
=
requests
.
get
(
url
,
timeout
=
(
settings
.
REQUESTS_CONNECT_TIMEOUT
,
settings
.
REQUESTS_READ_TIMEOUT
)
)
#POST回调
if
record
.
callback_type
==
CHANNEL_CALLBACK_TYPE
.
POST_CALLBACK
.
value
[
0
]:
response
=
requests
.
post
(
url
)
response
=
requests
.
post
(
url
,
timeout
=
(
settings
.
REQUESTS_CONNECT_TIMEOUT
,
settings
.
REQUESTS_READ_TIMEOUT
)
)
record
.
response
=
response
.
text
;
record
.
save
()
...
...
@@ -174,17 +176,16 @@ class Channel(View):
#获得渠道数据
try
:
data
=
Channel
.
__dict__
.
get
(
platform
)(
self
)
data
,
success
,
fail
=
Channel
.
__dict__
.
get
(
platform
)(
self
)
except
Exception
as
e
:
print
(
str
(
e
))
return
JsonResponse
({
'code'
:
1
,
'failMsg'
:
"not exists method to handle it!"
})
result
,
msg
=
PromotionChannel
.
record
(
request
,
sub_name
,
**
data
)
if
not
result
:
return
JsonResponse
(
{
'code'
:
1
,
'failMsg'
:
msg
}
)
return
JsonResponse
(
{
"code"
:
0
,
"failMsg"
:
""
}
)
return
JsonResponse
(
fail
(
msg
)
)
return
JsonResponse
(
success
(
msg
)
)
def
zuimei
(
self
):
...
...
@@ -194,5 +195,20 @@ class Channel(View):
data
=
self
.
request
.
GET
.
dict
()
data
.
update
({
"platform"
:
data
.
pop
(
'apptype'
,
''
),
"appid"
:
"jfq"
})
return
data
success
=
lambda
msg
:{
"code"
:
0
,
"failMsg"
:
""
}
fail
=
lambda
msg
:{
'code'
:
1
,
'failMsg'
:
msg
}
return
data
,
success
,
fail
def
guangdiantong
(
self
):
'''
广点通(腾讯广告平台)
'''
data
=
self
.
request
.
GET
.
dict
()
data
.
update
({
"device_id"
:
data
.
pop
(
'muid'
,
''
),
"appid"
:
"guangdiantong"
})
success
=
lambda
msg
:{
"ret"
:
0
,
"failMsg"
:
msg
}
fail
=
lambda
msg
:{
"ret"
:
1
,
'failMsg'
:
msg
}
return
data
,
success
,
fail
\ No newline at end of file
start_celery.sh
View file @
b5797ede
celery worker
-A
channels
-l
info
\ No newline at end of file
celery worker
-A
channels
-l
info
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