Exemplo n.º 1
0
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')
Exemplo n.º 2
0
Arquivo: app.py Projeto: 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')
Exemplo n.º 3
0
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')
Exemplo n.º 4
0
Arquivo: app.py Projeto: 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')