本文整理汇总了Python中users.User.objects方法的典型用法代码示例。如果您正苦于以下问题:Python User.objects方法的具体用法?Python User.objects怎么用?Python User.objects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类users.User
的用法示例。
在下文中一共展示了User.objects方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_login_techkids
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import objects [as 别名]
def get_login_techkids():
username = request.args.get('username')
password = request.args.get('password')
for user in User.objects(user_name=username):
if (user.password == password):
return json.dumps({"login_status": 1, "login_message": "Login Success", "link":"http://iliat.org/download.txt"})
return json.dumps({"login_status": 0, "login_message": "Login Failed"})
示例2: gmat_login
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import objects [as 别名]
def gmat_login():
user_name = request.form['username'];
password = request.form['password'];
for user in User.objects(user_name=user_name):
if(user.password == password):
return json.dumps({"login_status":1, "login_message":"Login Success"})
return json.dumps({"login_status":0, "login_message":"Login Failed"})
示例3: get
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import objects [as 别名]
def get(self, fb_id):
users = User.objects(facebook_id=fb_id)
if len(users) > 1:
raise {'status': 'fail', 'message': 'Multiple facebook id detected.'}
elif len(users) == 0:
return {'status': 'fail', 'message': 'Invalid facebook id.'}
user = users[0]
list_friend = []
for f in user.friends:
list_friend.append(f.facebook_id)
return {'status': 'success', 'friends': list_friend}
示例4: post
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import objects [as 别名]
def post(self, fb_id):
# Check training status
response = requests.get(
'https://api.projectoxford.ai/face/v1.0/persongroups/{}/training'.format(
persongroups_id
),
headers={
'Ocp-Apim-Subscription-Key': sub_key
}
)
response_json = response.json()
if response_json.get('error'):
return {'status': 'fail', 'message': response_json.get('error')}
if response_json.get('status') != 'succeeded':
return {'status': 'fail', 'message': 'The system is busy. Please try again.'}
# ====================================================================================
# Get a list of friends
users = User.objects(facebook_id=fb_id)
if len(users) > 1:
raise {'status': 'fail', 'message': 'Multiple facebook id detected.'}
elif len(users) == 0:
return {'status': 'fail', 'message': 'Invalid facebook id.'}
user = users[0]
list_friend = []
for f in user.friends:
list_friend.append(f.facebook_id)
# ====================================================================================
# Get a list of friends of friends
dict_fof = {}
for f_fb_id in list_friend:
# Get a list of friends
users = User.objects(facebook_id=f_fb_id)
if len(users) > 1:
raise {'status': 'fail', 'message': 'Multiple facebook id detected.'}
elif len(users) == 0:
return {'status': 'fail', 'message': 'Invalid facebook id.'}
user = users[0]
f_list_friend = []
for ff in user.friends:
if ff.facebook_id != fb_id:
f_list_friend.append(ff.facebook_id)
dict_fof[f_fb_id] = f_list_friend
# ====================================================================================
# Get upload file
file = request.files.get('file')
if file:
# Get the secure filename
filename = secure_filename(file.filename)
# Check for allowed extension
if allowed_file(file.filename):
# Save file to disk
upload_file_path = os.path.join(app.config['TMP_FOLDER'], filename)
file.save(upload_file_path)
# If there is upload file
if os.path.isfile(upload_file_path):
# Send upload file to detect faces
with open(upload_file_path, 'rb') as data_file:
response = requests.post(
'https://api.projectoxford.ai/face/v1.0/detect?returnFaceId=true&returnFaceLandmarks=true&returnFaceAttributes=age,gender',
headers={
'Content-Type': 'application/octet-stream',
'Ocp-Apim-Subscription-Key': sub_key
},
data=data_file.read()
)
response_json = response.json()
if not isinstance(response_json, list):
if response_json.get('error'):
return {'status': 'fail', 'message': response_json.get('error')}
# Remove uploaded file from the upload directory, as it has already been stored in database
os.remove(upload_file_path)
# Get return face_id, which are used to refer to the detected faces
list_face_id = []
dict_face_id = {}
for r in response_json:
list_face_id.append(r.get('faceId'))
dict_face_id[r.get('faceId')] = r.get('faceRectangle')
if len(list_face_id) == 0:
return {'status': 'fail', 'message': 'No face detected.'}
#.........这里部分代码省略.........
示例5: load_user
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import objects [as 别名]
def load_user(user_id):
return User.objects(id=user_id).first()