Пример #1
0
def add_data():
    if request.method == 'POST':
        message = json.loads(request.get_data(as_text=True))
        email_list = message['email']
        token = message['token']
        result = confirm_admin_token(token)  # 没有每个人唯一的Key
    response = Response()
    response.headers['Content-Type'] = 'application/json'
    response.headers['Access-Control-Allow-Origin'] = '*'
    response.headers['Access-Control-Allow-Headers'] = '*'
    if request.method == 'OPTIONS':
        return response
    return_json = {'code': 1, 'message': '网络异常', 'data': None}
    response.data = return_msg(return_json)
    if result == False:
        return response
    for email in email_list:
        if check_email(email) == False:
            logger.info('invalid email %s' % email)
            continue
        try:
            insert_people(email, '')
        except KeyError:
            pass
        except Exception as e:
            logger.info(e)
    return_json = {
        'code': 0,
        'message': 'update emails successfully',
        'data': None
    }
    response.data = return_msg(return_json)
    return response
def write_user():
    from faker import Faker
    fake = Faker()
    # print (fake.email())
    for i in range(0, 30):
        insert_people(name=fake.name(),
                      email=fake.email(),
                      token="token" + str(i))
Пример #3
0
 def test_insert_people_new_api(self):
     insert_people('[email protected],2020030001', 'Yang Li')
Пример #4
0
 def test_insert_people(self):
     insert_people('*****@*****.**', 'fake name')
     try:
         insert_people('*****@*****.**', 'fake name')
     except:
         pass