Esempio n. 1
0
def serve_meme_blank(name, ext):
    # STATS.hits.mark()
    # with STATS.latency.time():
    better_name = libmeme.fuzzy_meme(name)

    # should you redirect?
    if better_name != name or ext != IMG_DEXT:
        new_url = "/memeer/{n}.{e}".format(n=better_name, e=IMG_DEXT)
        LOG.info("redirecting to: ", new_url)
        return redirect(new_url)

    size = request.args.get("size", "")
    better_name_size = better_name + size

    resp = cache.get(better_name_size)

    if resp:
        return resp

    meme_img = libmeme.meme_image(better_name, "", "")
    f, length = libmeme.bufferize_image(meme_img, ext, size)
    resp = build_image_response(f, length, ext)

    cache.set(better_name_size, resp, timeout=5 * 60)
    return resp
Esempio n. 2
0
def serve_meme_blank(name, ext):
    # STATS.hits.mark()
    # with STATS.latency.time():
    better_name = libmeme.fuzzy_meme(name)

    # should you redirect?
    if better_name != name or ext != IMG_DEXT:
        new_url = "/memeer/{n}.{e}".format(n=better_name, e=IMG_DEXT)
        LOG.info("redirecting to: ", new_url)
        return redirect(new_url)

    size = request.args.get("size", "")
    better_name_size = better_name + size

    resp = cache.get(better_name_size)

    if resp:
        return resp

    meme_img = libmeme.meme_image(better_name, "", "")
    f, length = libmeme.bufferize_image(meme_img, ext, size)
    resp = build_image_response(f, length, ext)

    cache.set(better_name_size, resp, timeout=5 * 60)
    return resp
Esempio n. 3
0
def serve_meme_image(name, line_a, line_b, ext):
    better_name = libmeme.fuzzy_meme(name)

    # should you redirect?
    if better_name != name or ext != IMG_DEXT:
        line_a_format = quote(line_a)
        line_b_format = quote(line_b)
        new_url = SITE_ROOT + "/{n}/{a}/{b}.{e}".format(n=better_name, a=line_a_format, b=line_b_format, e=IMG_DEXT)
        LOG.info("redirecting to: ", new_url)
        return redirect(new_url)

    libmeme.meme_image(better_name, line_a, line_b)

    meme_img = libmeme.meme_image(better_name, line_a, line_b)
    f, length = libmeme.bufferize_image(meme_img, ext)
    resp = build_image_response(f, length, ext)

    return resp
Esempio n. 4
0
def serve_meme_image(name, line_a, line_b, ext):
    better_name = libmeme.fuzzy_meme(name)

    # should you redirect?
    if better_name != name or ext != IMG_DEXT:
        line_a_format = quote(line_a)
        line_b_format = quote(line_b)
        new_url = SITE_ROOT + "/{n}/{a}/{b}.{e}".format(
            n=better_name, a=line_a_format, b=line_b_format, e=IMG_DEXT)
        LOG.info("redirecting to: ", new_url)
        return redirect(new_url)

    libmeme.meme_image(better_name, line_a, line_b)

    meme_img = libmeme.meme_image(better_name, line_a, line_b)
    f, length = libmeme.bufferize_image(meme_img, ext)
    resp = build_image_response(f, length, ext)

    return resp