本文整理汇总了Python中models.Image.tags方法的典型用法代码示例。如果您正苦于以下问题:Python Image.tags方法的具体用法?Python Image.tags怎么用?Python Image.tags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Image
的用法示例。
在下文中一共展示了Image.tags方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: receive
# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import tags [as 别名]
def receive():
data = request.data
data = xmltodict.parse(data)['xml']
if data['MsgType'] == 'text':
return send_text(data['FromUserName'], 'hi')
if data['MsgType'] == 'image':
token = current_access_token()
file_url = 'https://api.weixin.qq.com/cgi-bin/media/get?access_token=%s&media_id=%s' % (token, data['MediaId'])
file = requests.get(file_url, stream=True).raw
i = Image()
i.image = file
uuid = shortuuid.ShortUUID().random(length=6)
while Image.objects(iid=uuid):
uuid = shortuuid.ShortUUID().random(length=6)
i.iid = uuid
i.title = data['MediaId']
i.user = system_user
i.description = ''
i.tags = []
i.save()
return send_text(
data['FromUserName'], '업로드 성공, 사진주소:%s%s' % (
request.url_root[:-1], url_for('light-cms.image', iid=i.iid)
)
)
示例2: drop
# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import tags [as 别名]
def drop():
file = request.files['file']
i = Image()
i.title = file.filename
i.image = file
uuid = shortuuid.ShortUUID().random(length=6)
while Image.objects(iid=uuid):
uuid = shortuuid.ShortUUID().random(length=6)
i.iid = uuid
if login.current_user.is_active():
i.user = login.current_user._get_current_object()
else:
i.user = system_user
i.description = ''
i.tags = []
i.save()
return jsonify(id=uuid)
示例3: gallery_drop
# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import tags [as 别名]
def gallery_drop(gid):
if not login.current_user.is_active():
flash('앨범기능엔 로그인이 필요합니다')
return redirect(url_for('light-cms.user_login'))
g = Gallery.objects.get_or_404(gid=gid)
file = request.files['file']
i = Image()
i.gallery.append(g)
i.title = file.filename
i.image = file
uuid = shortuuid.ShortUUID().random(length=6)
while Image.objects(iid=uuid):
uuid = shortuuid.ShortUUID().random(length=6)
i.iid = uuid
i.user = login.current_user._get_current_object()
i.description = ''
i.tags = []
i.save()
return jsonify(id=uuid)