コード例 #1
0
ファイル: app.py プロジェクト: abdelhai/avatar
def init_color(initials, color):
    # print domain(request.referrer)
    try:
        host = domain(request.referrer)
    except:
        host = 'unknown'

    uhid = '{}_{}_{}'.format(initials,color,host)
    obj = AvatarData.objects(uhid=uhid).first()
    if not obj:
        svg = svg_template.format(color,initials)
        newobj = AvatarData(uhid=uhid, initials=initials, color=color)
        newobj.save()
    else:
        initials = obj.initials
        color = obj.color
        svg = svg_template.format(color,initials)

    return Response(svg, status=200, mimetype='image/svg+xml')
コード例 #2
0
ファイル: app.py プロジェクト: bishug/avatar
def init_color(initials, color):
    # print domain(request.referrer)
    try:
        host = domain(request.referrer)
    except:
        host = 'unknown'

    uhid = '{}_{}_{}'.format(initials, color, host)
    obj = AvatarData.objects(uhid=uhid).first()
    if not obj:
        svg = svg_template.format(color, initials)
        newobj = AvatarData(uhid=uhid, initials=initials, color=color)
        newobj.save()
    else:
        initials = obj.initials
        color = obj.color
        svg = svg_template.format(color, initials)

    return Response(svg, status=200, mimetype='image/svg+xml')
コード例 #3
0
ファイル: app.py プロジェクト: abdelhai/avatar
def init_color_ident(initials, color, ident):
    try:
        host = domain(request.referrer)
    except:
        host = 'unknown'
    print request.referrer, host
    uhid = '{}_{}_{}_{}'.format(initials,color,ident,host)
    obj = AvatarData.objects(uhid=uhid).first()
    if not obj:
        if color == '!':
            randy = randint(0,920)
            color = colors_[randy]

        svg = svg_template.format(color,initials)
        newobj = AvatarData(uhid=uhid, initials=initials, color=color)
        newobj.save()
    else:
        initials = obj.initials
        color = obj.color
        svg = svg_template.format(color,initials)

    return Response(svg, status=200, mimetype='image/svg+xml')
コード例 #4
0
ファイル: app.py プロジェクト: bishug/avatar
def init_color_ident(initials, color, ident):
    try:
        host = domain(request.referrer)
    except:
        host = 'unknown'
    print request.referrer, host
    uhid = '{}_{}_{}_{}'.format(initials, color, ident, host)
    obj = AvatarData.objects(uhid=uhid).first()
    if not obj:
        if color == '!':
            randy = randint(0, 920)
            color = colors_[randy]

        svg = svg_template.format(color, initials)
        newobj = AvatarData(uhid=uhid, initials=initials, color=color)
        newobj.save()
    else:
        initials = obj.initials
        color = obj.color
        svg = svg_template.format(color, initials)

    return Response(svg, status=200, mimetype='image/svg+xml')