Commit beadfd91 beadfd913ea6fa5906791a107c7ab3aba7c64c46 by 杨俊

Init

0 parents
No preview for this file type
.idea
*.exe
*.pyc
*.log
api/static
HisinApi/settings.py
\ No newline at end of file
# 使用方 Python 基础镜像作为基础
FROM python:3.7.4
# 设置工目录
WORKDIR /
RUN apt-get update && apt-get install -y libsndfile1 ffmpeg
# 将 requirements.txt 复到容器中
COPY requirements.txt .
# 安装赖包
RUN pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
# 将整个项目复制到容器中
COPY . .
# 运行 Django 服务器
CMD python manage.py runserver 0.0.0.0:8000
\ No newline at end of file
No preview for this file type
import pymysql
pymysql.version_info = (1, 4, 13, "final", 0)
pymysql.install_as_MySQLdb()
\ No newline at end of file
"""
ASGI config for HisinApi project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'HisinApi.settings')
application = get_asgi_application()
"""HisinApi URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from api.ApiList import login,index,audition,my,notifications,appversion,community
urlpatterns = [
#登录注册模块
path('admin', admin.site.urls),
path('', index.index),
path('api/sendsms',login.sendsms),
path('api/v2/sendsms', login.v2sendsms),
path('api/login', login.user_login),
path('api/sms_verify/login', login.sms_verify_login),
path('api/wechat/auth', login.wechatAuth),
path('api/register', login.register),
path('api/v2/register', login.v2register),
path('api/v3/register', login.v3register),
path('api/reset', login.restPwd),
path('api/business_list', login.businessList),
#首页模块
path('api/user', index.user),
path('api/activity/view', index.UserViewActivity),
path('api/examines', index.Examines.as_view()), #注册用户待审核列表
path('api/activitys', index.GetActivitys.as_view()),
path('api/v2/activitys', index.V2GetActivitys.as_view()), #去掉收藏活动
path('api/v3/activitys', index.V3GetActivitys.as_view()), #加入收藏活动
path('api/examine_status', index.examineStatus.as_view()),
path('api/banner', index.banners),
path('api/v2/banner', index.v2banners),
path('api/banner/detail', index.bannerDetail),
path('api/activity/attend_user',index.GetActivityUser.as_view() ),
path('api/activity/unlike', index.Unlike.as_view()),
path('api/activity/completes', index.GetCompleteActivity.as_view()),
path('api/events', index.Events),
path('api/action', index.Action),
path('api/band_list', index.BandList.as_view()),
path('api/band_detail', index.BandDetail.as_view()),
path('api/band_link_activity', index.BandLinkActivity.as_view()),
path('api/activity/recommend', index.RecommenCasedList.as_view()),
#我的模块
path('api/upload', my.upload),
path('api/user/avatar',my.updateUserAvatar),
path('api/user/activitys',my.MyActivitys.as_view()),
path('api/user/activity_detail', my.SaveOrSubmitList),
path('api/v2/user/activity_detail', my.V2SaveOrSubmitList),
path('api/user/activity_sumbit', my.UpdateSumbit),
path('api/user/submit_examine', my.SubmitExamine),
path('api/v2/user/submit_examine', my.V2SubmitExamine),
path('api/user/set_tag', my.SetUserTags),
path('api/user/tag_list', my.getUserTag),
path('api/user/unbind', my.unbind),
path('api/user/bind', my.bind),
path('api/admin/activitys', my.AdminActivitys.as_view()),
path('api/admin/submit_list', my.AdminSubmitList),
path('api/v2/admin/submit_list', my.V2AdminSubmitList),
path('api/user/singer_list', my.MySinget.as_view()),
path('api/user/singer', my.SingerInfo.as_view()),
path('api/v2/user/singer', my.SingerInfoV2.as_view()),
path('api/user/singer/avtivitys', my.SingerAvtivity.as_view()),
path('api/user/singer/complete', my.SingerComplete.as_view()), #我的歌手-被选中
path('api/user/singer/avtivity_detail', my.AvtivityDetail.as_view()),
path('api/user/banner', my.banners),
path('api/user/listen', my.Listen.as_view()),
path('api/user/ta_collection', my.TaCollection.as_view()),
path('api/user/ta_audition', my.TaAudition.as_view()),
path('api/user/resume_like', my.ResumeLike.as_view()),
path('api/user/remove_save', my.remove_save),
path('api/user/editor', my.editor),
path('api/user/change_phone', my.change_phone),
path('api/user/sound', my.UserSound.as_view()),
path('api/user/home', my.UserHome.as_view()),
path('api/user/tidings', my.UserTidings.as_view()),
path('api/user/follow', my.UserFollow.as_view()),
path('api/user/following', my.UserFollowing.as_view()),
path('api/user/find_singer', my.FindSinger.as_view()),
path('api/user/visitors', my.Visitors.as_view()),
path('api/user/remove_device', my.RemoveDevice.as_view()),
path('api/user/avtivitys/price', my.AvtivitysPrice.as_view()),
path('api/avtivitys/price_info', my.AvtivitysPriceInfo.as_view()),
#管理员查看试唱确认合作
path('api/admin/activity/confirm',my.ConfirmSinger),
#注销账号
path('api/user/delete', my.UserDelete),
#试唱模块
path('api/audition/materials', audition.AuditionMaterials), #小程序端物料,要升降调文件
path('api/activity/materials', audition.ActivityMaterials), #app 端物料,无须升降调文件
path('api/audition/send_materials', audition.SendMaterials), #自主上传方式发送物料
path('api/audition/split_audio', audition.SplitAudio),
path('api/audition/auto_submit', audition.AotoSubmit),
path('api/audition/online_save', audition.OnlineSave),
path('api/audition/join', audition.JoinActivity), # APP线上保存或提交
path('api/audition/upload', audition.UploadAudio),
path('api/audition/mixin_preview', audition.MixinPreview),
path('api/audition/part_preview', audition.PartPreview),
path('api/audition/mixin_check', audition.MixinCheck),
path('api/audition/collection', audition.Collection.as_view()),
path('api/audition/remove_collection', audition.cancelcollection),
#活动确定分享人
path('api/audition/share_users_list', audition.ShareUsersList.as_view()),
path('api/audition/share_users', audition.ShareUsers.as_view()),
#社区模块
path('api/community/tidings', community.Tidings.as_view()),
path('api/community/tidings/selete_activity', community.SeleteActivity.as_view()),
path('api/community/tidings_list', community.TidingsList.as_view()),
path('api/community/tidings/show', community.TidingsShow.as_view()),
path('api/community/tidings/limiting', community.TidingsLimiting.as_view()),
path('api/community/tidings/report', community.TidingsReport.as_view()),
path('api/community/tidings/record_user', community.RecordUser.as_view()),
path('api/community/tidings/interacts',community.TidingsInteracts.as_view()),
path('api/community/tidings/chat', community.TidingsChat.as_view()),
path('api/community/chat/relation', community.ChatRelation.as_view()),
path('api/community/chat/agent', community.ChatAgent.as_view()),
path('api/community/chat/agent_record', community.ChatAgentRecord.as_view()),
path('api/community/unlike', community.Unlike.as_view()),
path('api/community/tidings/comments', community.TidingsComments.as_view()), #动态评论
#消息通知模块
path('api/notifica/read_message', notifications.read),
path('api/notifica/system_message', notifications.SystemMessage.as_view()),
#极光推送
path('api/notifica/push', notifications.push_notifications),
#积分接口
path('api/user/point', my.UserPoint.as_view()),
# 用户协议
path('h5/user_agreement', index.useragreement),
#分享活动页面
path('h5/share/<id>/', index.songshare),
# 分享动态页面
# path('h5/sharetidings/<id>/', index.tidingsshare),
# app分享页面
path('h5/shareapp/', index.appshare),
#版本更新
path('api/app/version', appversion.versioninfo),
#获取app分享内容
path('api/share/dictionary_list', my.sharechildlist),
path('api/share/dictionary', my.sharechild),
#客服列表
path('api/customer_service', my.CustomerService.as_view()),
]
"""
WSGI config for HisinApi project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'HisinApi.settings')
application = get_wsgi_application()
#### Python版本
- Python 3.7.0
#### 依赖安装
- pip install -r requirements.txt
#### 本地项目启动命令
- python manage.py runserver
#### 线上项目进程管理,启动/更新
- 服务已经配置supervisor进程管理
- git pull拉取代码后会更新服务
#### 主要目录结构说明
> HisinApi 文件主目录
>> api 接口编写主目录
> > > ApiList 接口模块列表
> > >
> > > jobs 定时任务脚本
> > >
> > > templates 页面文件
> > >
> > > admin.py
> > >
> > > apps.py
> > >
> > > loggin.py 日志模块
> > >
> > > models.py 数据表模型文件
> > >
> > > serializers.py 接口返回数据序列化,定义返回字段和结构
> > >
> > > tests.py
> > >
> > > verification.py 接口接受参数校验文件
> > >
> > > views.py 接口通用方法都写在这里
>>
>> HisinApi 项目环境配置
> > > settings.py 环境配置文件
> > >
> > > urls.py 接口路由定义文件
> >
> > manage.py 项目启动文件
> >
> > requirements.txt 项目依赖文件
\ No newline at end of file
No preview for this file type
from api import models
from api.views import ResponseFactory
from django.http import JsonResponse
from api import serializers
def versioninfo(requests):
"""
版本更新信息
:param requests:
:return:
"""
if requests.method != 'GET':
return JsonResponse(ResponseFactory(code=400, message="不支持的请求方法", data=None, status='fail'))
os = requests.GET['os']
app_version = requests.GET['app_version']
# verobject = models.AppVersion.objects.filter(os=os,app_ver__gt=app_version,deleted_at=None).first()
# if verobject:data = serializers.AppVersionSerializer(models.AppVersion.objects.filter(os=os,deleted_at=None).last(),many=False,context={"app_version":app_version,"os":os}).data
# else:data = serializers.AppVersionSerializer(models.AppVersion.objects.filter(os=os,deleted_at=None).last(),many=False,context={"app_version":app_version,"os":os}).data
data = serializers.AppVersionSerializer(models.AppVersion.objects.filter(os=os, deleted_at=None).last(), many=False,context={"app_version": app_version, "os": os}).data
return JsonResponse(ResponseFactory(code=200, message="获取成功", data=data, status='success'))
\ No newline at end of file
from api.views import AuthPermissionRequired,get_user_info
from django.http import JsonResponse
from api.views import ResponseFactory,PageNumberPagination,GetWxToken,pushSubscribeMessage,WeChatApi,JPush
from rest_framework.decorators import api_view
from api import models,verification,serializers
import json
from django.utils.decorators import method_decorator
from rest_framework.views import APIView
def push_notifications(request):
if request.method != "POST":
return JsonResponse(ResponseFactory(code=400, message="不支持的请求方法", data=None, status='fail'))
post_data = json.loads(request.body)
obj = verification.PushNotifications(post_data)
if not obj.is_valid():
return JsonResponse(ResponseFactory(code=400, message=verification.error_message(obj), data=None, status='fail'))
obj = obj.clean()
jdata = {"title": obj.get('title'), "content": obj.get('content'), "content_type": "text",
"receiver_value": obj.get('receivers'),
"extras": {"type": post_data.get('type',""), "value": post_data.get('value',"")}}
result = JPush().jpush_v3(jdata)
return JsonResponse(result)
@AuthPermissionRequired()
def read(request):
put_data = json.loads(request.body)
user_id = get_user_info(request)['id']
if request.method == "PUT":
type = put_data.get('type')
#我的歌手审核消息已读
if type == 1:
models.UserMessages.objects.filter(type=type,receiver_id=user_id,sender_id=put_data['sender_id'],deleted_at=None).update(is_read=1)
return JsonResponse(ResponseFactory(code=200, message="已阅读", data=None, status='success'))
# 我的歌手收藏消息已读
elif type == 2:
models.UserMessages.objects.filter(type=type,receiver_id=user_id,deleted_at=None).update(is_read=1)
return JsonResponse(ResponseFactory(code=200, message="已阅读", data=None, status='success'))
# 我的歌手或平台用户试唱消息已读(注意区分是绑定用户,还是平台用户)
elif type == 3:
models.UserMessages.objects.filter(type=type,sender_id=put_data['sender_id'],receiver_id=user_id,activity_id=put_data['activity_id'],is_bind=put_data['is_bind'],deleted_at=None).update(is_read=1)
return JsonResponse(ResponseFactory(code=200, message="已阅读", data=None, status='success'))
#系统消息已读
elif type == 4:
models.UserMessages.objects.filter(type__in=[4,5,6,7,8,9,10,11,12,13,14], receiver_id=user_id, deleted_at=None).update(is_read=1)
return JsonResponse(ResponseFactory(code=200, message="已阅读", data=None, status='success'))
else:
return JsonResponse(ResponseFactory(code=400, message="不支持的请求方法", data=None, status='fail'))
class SystemMessage(APIView):
@method_decorator(AuthPermissionRequired())
def get(self,request):
user_id = get_user_info(request)['id']
queryset = models.UserMessages.objects.filter(type__in=[4,5,6,7,8,9,10,11,12,13,14],receiver_id=user_id,deleted_at=None).order_by('-created_at')
page_obj = PageNumberPagination()
page_data = page_obj.paginate_queryset(queryset, request)
ser_obj = serializers.SystemMessageSerializer(page_data, many=True)
data = {"message": ser_obj.data, "count": queryset.count()}
return JsonResponse(ResponseFactory(code=200, message="获取成功", data=data, status='success'))
\ No newline at end of file
File mode changed
from django.contrib import admin
from django.apps import AppConfig
class WxMiniapiConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'api'
File mode changed
File mode changed
import logging
# 获取logger对象
logger = logging.getLogger(__name__)
\ No newline at end of file
import jwt
import json
from HisinApi import settings
from api.models import SystemHttpLogs
from django.utils import timezone
from api.views import object_to_json
import time
from api.loggin import logger
class ApiLogs(object):
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
response = self.get_response(request)
try:
body = json.loads(request.body.decode('utf-8'))
except:
body = {}
header = object_to_json(request.headers)['_store']
if request.method == 'GET':
query = request.GET
else:
query = request.POST
request_data = {"body":body,"header":header,"query":query}
try:body = json.loads( response._container[0].decode('utf-8'))
except: body = None
response_data = {"body":body, "header": object_to_json(response.headers)['_store'],"code":response.status_code}
try:
try:
auth = request.META.get('HTTP_AUTHORIZATION').split()
dict = jwt.decode(auth[1], settings.SECRET_KEY, algorithms=['HS256'])
user_id = dict.get('data').get('id')
except:
user_id = 0
SystemHttpLogs(
guard='App',
user_id=user_id,
method=request.method,
uri=request.path,
ip=request.META['REMOTE_ADDR'],
request=request_data,
response=response_data,
consume =response.headers['time'],
created_at=timezone.now().strftime("%Y-%m-%d %H:%M:%S")).save()
except Exception as e:
logger.info('API Log Error:{}'.format(e))
return response
class ResponseTime:
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
start_time = time.time()
response = self.get_response(request)
duration = time.time() - start_time
response["time"] = int(duration * 1000)
return response
\ No newline at end of file
import time
import schedule
import threading
from api import models
from django.utils import timezone
from django.db.models import F, Func
from django.db.models.functions import Now
def project_confirmation_times():
projects = models.Projects.objects.filter(status=1,deleted_at=None)
for project in projects:
#匹配的活动均值
l1 = list()
days_diff = Func(F('match_at') - F('publish_at'), function='ABS')
results = models.Activitys.objects.filter(status__in=[3,5],project_id=project.id).annotate(days_diff=days_diff)
for result in results:
try:l1.append(result.days_diff.days)
except:l1.append(0)
# 未匹配的活动均值
days_diff = Func(Now() - F('publish_at'),function='ABS')
deltas = models.Activitys.objects.filter(status=1,project_id=project.id).annotate(days_diff=days_diff)
for delta in deltas:
try:l1.append(delta.days_diff.days)
except:pass
try:mean = sum(l1) / len(l1)
except: mean = 0
models.ProjectConfirmationTime.objects.update_or_create(
project_id=project.id,
defaults={'average_day': mean,'created_at':timezone.now().strftime("%Y-%m-%d %H:%M:%S"),'updated_at':timezone.now().strftime("%Y-%m-%d %H:%M:%S")}
)
def job1():
threading.Thread(target=project_confirmation_times).start()
schedule.every().day.at("02:00").do(job1)
# schedule.every(1).minutes.do(job1)
def run():
while True:
schedule.run_pending()
time.sleep(1)
File mode changed
This diff could not be displayed because it is too large.
# -*-coding:utf-8 -*-
import os
import requests
from pydub import AudioSegment
from django.core.cache import caches
import time, random, json
import base64
import hashlib
from Crypto.Cipher import AES
from Crypto import Random
appid = "wx0f3844b1458ccfb9"
secret = "f9fa09c6cf3b4db19906d876d9c64755"
def split_mp3():
new_name = './static/out444.mp3'
use_name = './static/12345.mp3'
input_music = AudioSegment.from_mp3(use_name)
# 截取音频后31000毫秒 = 31秒
output_music = input_music[31000:]
# 保存音频,指定音频比特率为64k
output_music.export(new_name, bitrate="64k")
print(new_name + '完成!')
def WeChatApi(code):
appid = "wx0f3844b1458ccfb9"
secret = "f9fa09c6cf3b4db19906d876d9c64755"
parmas = {
'appid': appid,
'secret': secret,
'js_code': code,
'grant_type': 'authorization_code'
}
url = 'https://api.weixin.qq.com/sns/jscode2session'
r = requests.get(url, params=parmas).json()
print (r)
try:
return r['openid'],r['unionid']
except:
return None,None
def get_access_toke():
url = 'https://api.weixin.qq.com/cgi-bin/token'
parmas = {
"grant_type":"client_credential",
"appid":appid,
"secret":secret
}
r = requests.get(url,params=parmas).json()
print (r)
def WxPushInfo(data):
nickname = data['nickname']
result = data['result']
remarks = data['remarks']
touser = data['touser']
access_token = data['access_token']
url = 'https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token={}'.format(access_token)
postdata = {
"touser":touser,
"template_id":"B0s4RIurXwoegzK4tLWNU_H-xB2kUIE_E_ft5Ur6Auk",
"data":{
"name10":{"value":nickname},
"phrase5":{"value":result},
"thing11":{"value":remarks}
}
}
r = requests.post(url, json=postdata).json()
print(r)
def GetWxToken():
token = caches['default'].get('wx_access_token')
if not token:
appid = "wx0f3844b1458ccfb9"
secret = "f9fa09c6cf3b4db19906d876d9c64755"
url = 'https://api.weixin.qq.com/cgi-bin/token'
parmas = {
"grant_type":"client_credential",
"appid":appid,
"secret":secret
}
r = requests.get(url,params=parmas).json()
caches['default'].add('wx_access_token', r['access_token'] , r['expires_in']) #expires_in
return r['access_token']
else:
return token
def Test(data):
import hashlib
channel = 'register_audit_channel'
open_id = data['open_id']
url = 'http://hi-sing-admin-dev.hikoon.com/api/provider/wechat/pushSubscribeMessage'
md5_str = channel + open_id + 'tb0iwb7TE9TIbkG8iFsxldrHJRFdeP1g'
hl = hashlib.md5()
hl.update(md5_str.encode(encoding='utf8'))
secret = hl.hexdigest()
data = {
'secret': secret,
'channel': channel,
'open_id': open_id,
'data': data['data']
}
r = requests.post(url,json=data).json()
print (r)
def test():
import requests
url = "127.0.0.1:8000/api/register"
payload = {
"nick_name": "🍹🐼💑",
"real_name": "魏晗13457",
"phone": "17780983939",
"email": "17qwe111@qq.com",
"origin_type": "Other",
"remarks": "黄辉浩",
"role": "SystemUser",
"password": "112358ys",
"confirm_password": "112358ys",
"sms_code": 123456,
"vx_code":"051vPN000xA8EN1rW2100URGiX3vPN0t"
}
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, json=payload)
print(response.text)
def toMp3():
import os
path = './static/'
file = '1234.m4a'
os.system("ffmpeg -i "+ path+file+ " " + path+ ".mp3" )
class JPush():
def __init__(self):
self.app_key = '860a3d4ecfaf3c38eb539c4e'
self.master_secret = 'df208c0eb485ed3ab3b18ff2'
def https_request(self, body, url, content_type=None, version=None, params=None):
https = requests.Session()
https.auth = (self.app_key,self.master_secret)
headers = {}
headers['user-agent'] = 'jpush-api-python-client'
headers['connection'] = 'keep-alive'
headers['content-type'] = 'application/json;charset:utf-8'
response = https.request('POST', url, data=body, params=params, headers=headers)
print (response.text)
print (dict(json.loads(response.content), **{'status_code': response.status_code}))
return dict(json.loads(response.content), **{'status_code': response.status_code})
def push_params_v3(self,title,content, receiver_value=None,content_type=None, extras=None, platform="ios,android"):
sendno = int(random.randint(1, 999))
payload = dict()
payload['platform'] = platform
payload['audience'] = {
"alias": receiver_value
}
payload["inapp_message"] = {"inapp_message": False}
payload['notification'] = {
"android": {"alert": content,"badge_add_num": 1,"alternate_alert": "","style": 0,"category": "","priority": 0,"title": title,"intent": {"url": ""},"alert_type": 7, "alternate_title": "", "extras": extras },
"ios": {"alert": content, "sound": "default", "extras": extras},
}
payload['options'] = {"apns_production": False, "time_to_live": 86400, 'sendno': sendno,
"third_party_channel":{
"xiaomi": {"importance":"NORMAL","distribution":"secondary_push","distribution_fcm":"secondary_fcm_push"},
"huawei": {"importance": "NORMAL"},
# "honor": {"importance": "NORMAL"},
# "meizu": {"importance": "NORMAL"},
"oppo": {"importance": "NORMAL"},
"vivo": {"importance": "NORMAL"},
}
}
return payload
def jpush_v3(self, data):
payload = self.push_params_v3(title=data['title'],content=data['content'],content_type=data['content_type'],receiver_value=data['receiver_value'],extras=data['extras'])
body = json.dumps(payload)
return self.https_request(body, "https://api.jpush.cn/v3/push", 'application/json', version=1)
def get_alias():
url = 'https://device.jpush.cn/v3/aliases/test189'
token = str(base64.b64encode(b'860a3d4ecfaf3c38eb539c4e:df208c0eb485ed3ab3b18ff2'),'utf-8')
print (token)
headers = {
'Authorization': 'Basic {}'.format(token),
'Accept': 'application / json'
}
resp = requests.get(url,headers=headers).text
print (resp)
def remove_alias():
url = 'https://device.jpush.cn/v3/aliases/test189'
token = str(base64.b64encode(b'860a3d4ecfaf3c38eb539c4e:df208c0eb485ed3ab3b18ff2'), 'utf-8')
headers = {
'Authorization': 'Basic {}'.format(token),
'Accept': 'application / json'
}
data = {
"registration_ids":{"remove": ["121c83f760d835d731c"]}
}
resp = requests.post(url,headers=headers,json=data).text
print (resp)
def Msg_Push_Server(data):
secret = 'hNA32TZVxFGL9xv526Yg74XSNcutM3DiqfktZcHq0084jI6o2VetEjAndY8zlNTP'
p = '{channel}&{data}&{secret}&{time}'.format(channel=data['channel'],data=data['data'],secret=secret,time=data['time']).encode()
p = base64.b64encode(p)
hl = hashlib.md5()
hl.update(p)
sign = hl.hexdigest()
data['sign'] = sign
data['data'] = json.loads(data['data'])
url = "https://hi-sing-admin-dev.hikoon.com/api/provider"
resp = requests.request('POST',url,json=data).text
if __name__ == '__main__':
# data = {"title":"标题","content":"测试推送","content_type":"text","receiver_value":['test189'],"extras":{"type":"","value":""}}
# JPush().jpush_v3(data)
# TLSSigAPIv2.main()
# get_alias()
# remove_alias()
data = {"channel":"ActivityPublish","data":'{"activityId":69}',"time":int(time.time())}
Msg_Push_Server(data)
This diff is collapsed. Click to expand it.
File mode changed
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'HisinApi.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
aliyun-python-sdk-core==2.13.35
aliyun-python-sdk-kms==2.15.0
django==3.2.12
django-redis-cache==3.0.1
django-rest-jwt==0.1.46
djangorestframework==3.13.1
djangorestframework-jwt==1.11.0
gevent==21.1.2
mysql-connector-python==8.0.18
oss2==2.14.0
PyJWT==2.7.0
PyMySQL==0.10.1
redis==3.5.3
requests==2.25.0
django-ratelimit==3.0.1
librosa==0.9.1
pydub==0.25.1
pyroomacoustics==0.7.3
eyed3==0.9.6
jieba==0.42.1
twilio==8.2.0
django_redis
matplotlib
schedule