本文整理汇总了Python中users.User.name方法的典型用法代码示例。如果您正苦于以下问题:Python User.name方法的具体用法?Python User.name怎么用?Python User.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类users.User
的用法示例。
在下文中一共展示了User.name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import name [as 别名]
def post(self):
# Get user information from POST request
# fb_id = request.form.get('facebook_id')
# name = request.form.get('name')
fb_id = request.json.get('facebook_id')
name = request.json.get('name')
friends = request.json.get('friends')
if not fb_id or not name:
return {'status': 'fail', 'message': 'Please specify facebook id and name.'}
# Create a User object
user = User()
user.facebook_id = fb_id
user.name = name
for f in friends:
friend = Friend()
friend.facebook_id = f.get('facebook_id')
friend.name = f.get('name')
user.friends.append(friend)
# Connect to Face API
response = requests.post(
'https://api.projectoxford.ai/face/v1.0/persongroups/{}/persons'.format(persongroups_id),
json={
'name': fb_id,
'userData': name
},
headers={
'Ocp-Apim-Subscription-Key': sub_key
}
)
response_json = response.json()
if response_json.get('error'):
return {'status': 'fail', 'message': response_json.get('error')}
user.person_id = response_json.get('personId')
user.save()
# Return user information
return {'status': 'success'}
示例2: signup
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import name [as 别名]
def signup():
if current_user.is_authenticated():
return redirect(url_for('user.index'))
loginForm = LoginForm()
form = SignupForm(next=request.args.get('next'))
if form.validate_on_submit():
user = User()
user.email = form.email.data.strip()
user.name = form.name.data.strip()
user.password = form.password.data
user.save()
if login_user(user):
return redirect(form.next.data or url_for('users.index'))
return render_template('frontend/login.html',
loginForm=loginForm,
signupForm=form)
示例3: create_profile
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import name [as 别名]
def create_profile():
if current_user.is_authenticated():
return redirect(url_for('users.index'))
form = CreateProfileForm()
if form.validate_on_submit():
user = User()
user.email = form.email.data.strip()
user.password = form.password.data
user.github_id = session['github_id']
user.name = session['name']
user.github_username = session['github_username']
user.oauth_token = session['oauth_token']
user.location = session['location']
user.save()
if login_user(user):
flash(_("Logged in"), 'success')
return redirect(url_for('users.index'))
return render_template('frontend/create_profile.html',
form=form)