Merge remote-tracking branch '210.77.77.77/master'
This commit is contained in:
commit
df4aaf1c17
|
@ -18,11 +18,3 @@ from django.core.wsgi import get_wsgi_application
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'NewMediaMonitoring.settings')
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'NewMediaMonitoring.settings')
|
||||||
sys.path.append("/var/www/p3/newmediamonitoring/current")
|
sys.path.append("/var/www/p3/newmediamonitoring/current")
|
||||||
application = get_wsgi_application()
|
application = get_wsgi_application()
|
||||||
try:
|
|
||||||
application = get_wsgi_application()
|
|
||||||
except Exception:
|
|
||||||
# Error loading applications
|
|
||||||
if 'mod_wsgi' in sys.modules:
|
|
||||||
traceback.print_exc()
|
|
||||||
os.kill(os.getpid(), signal.SIGINT)
|
|
||||||
time.sleep(2.5)
|
|
||||||
|
|
|
@ -18,3 +18,9 @@ source .venv/bin/activate
|
||||||
python manage.py make migrations
|
python manage.py make migrations
|
||||||
python manage.py migrate
|
python manage.py migrate
|
||||||
```
|
```
|
||||||
|
|
||||||
|
# 查看服务器apache 内存使用情况
|
||||||
|
|
||||||
|
```shell
|
||||||
|
sudo /usr/sbin/passenger-memory-stats
|
||||||
|
```
|
|
@ -0,0 +1,2 @@
|
||||||
|
import NewMediaMonitoring.wsgi
|
||||||
|
application = NewMediaMonitoring.wsgi.application
|
|
@ -21,7 +21,7 @@ class VerifyCode(models.Model):
|
||||||
|
|
||||||
def is_in_progress(self):
|
def is_in_progress(self):
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
return snow <= self.timeouted
|
return now <= self.timeouted
|
||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|
|
@ -1,7 +1,30 @@
|
||||||
|
from aliyunsdkcore.client import AcsClient
|
||||||
|
from aliyunsdkcore.request import CommonRequest
|
||||||
|
|
||||||
import random
|
import random
|
||||||
|
|
||||||
def sent_sms_code(phone):
|
def sent_sms_code(phone):
|
||||||
pass
|
client = AcsClient('LTAIBfgqfC2fpIDF', 'ocBzC2UvguYbyR6coNGYdPiV5HdWbC', 'cn-hangzhou')
|
||||||
|
request = CommonRequest()
|
||||||
|
request.set_accept_format('json')
|
||||||
|
request.set_domain('dysmsapi.aliyuncs.com')
|
||||||
|
request.set_method('POST')
|
||||||
|
request.set_protocol_type('https') # https | http
|
||||||
|
request.set_version('2017-05-25')
|
||||||
|
request.set_action_name('SendSms')
|
||||||
|
|
||||||
|
request.add_query_param('RegionId', "cn-hangzhou")
|
||||||
|
request.add_query_param('PhoneNumbers', "13993199566")
|
||||||
|
request.add_query_param('SignName', "短信验证")
|
||||||
|
request.add_query_param('TemplateCode', "SMS_12330409")
|
||||||
|
request.add_query_param('TemplateParam', '{"number":"1111"}')
|
||||||
|
|
||||||
|
response = client.do_action(request)
|
||||||
|
print(type(response.decode('utf8')))
|
||||||
|
|
||||||
def generate_code():
|
def generate_code():
|
||||||
return random.randint(1000, 9999)
|
return random.randint(1000, 9999)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sent_sms_code('13993199566')
|
|
@ -3,7 +3,10 @@ from django.http import HttpResponse, JsonResponse
|
||||||
from django.contrib.auth import get_user_model, authenticate, login
|
from django.contrib.auth import get_user_model, authenticate, login
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
from django_token.models import Token
|
from django_token.models import Token
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
from .models import VerifyCode
|
||||||
|
from .utils import generate_code, send_sms_code
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
username = request.GET.get('username')
|
username = request.GET.get('username')
|
||||||
|
@ -66,8 +69,13 @@ def send_code(request):
|
||||||
code = generate_code()
|
code = generate_code()
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
after_10mins = now + datetime.timedelta(minutes=10)
|
after_10mins = now + datetime.timedelta(minutes=10)
|
||||||
VerifyCode.objects.create(code=code, phone=phone, category=category)
|
response = send_sms_code(phone, code)
|
||||||
return JsonResponse({'status': 'success'})
|
result = response.decode('utf8')
|
||||||
|
if "OK" in result:
|
||||||
|
VerifyCode.objects.create(code=code, phone=phone, category=category)
|
||||||
|
return JsonResponse({'status': 'success'})
|
||||||
|
return JsonResponse({'status': 'error', 'message': '验证码发送失败'})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Django~=2.2.15
|
Django~=2.2.15
|
||||||
# django-bootstrap3
|
django-bootstrap3
|
||||||
# django-simple-captcha
|
django-simple-captcha
|
||||||
# psycopg2-binary
|
psycopg2-binary
|
||||||
# django-cors-headers
|
django-cors-headers
|
||||||
|
aliyun-python-sdk-core-v3
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue