Ejemplo n.º 1
0
def process(rnd, requests):
    requester = Requester()
    with requester.requests():
        # Process all requests.
        for req in requests:
            req = Bunch(req)
            if 'flags' not in req:
                req.flags = 0
            if 'content' in req:
                req.content = Bunch(req.content)
            ROUTER[req.action, req.type](requester, req)
    requester.submit(rnd)
Ejemplo n.º 2
0
def render(rnd, board_id=1):
    # Trigger a redraw.
    requester = Requester()
    with requester.requests():
        requester.update_board(board_id)
    requester.submit(rnd)

    # Get the image.
    img = rnd.get_png(board_id)

    # Return as PNG
    output = io.BytesIO(img)
    return output
Ejemplo n.º 3
0
def process(requests):
    requester = Requester()
    with requester.requests():
        # Process all requests.
        for req in requests:
            req = Bunch(req)
            if 'flags' not in req:
                req.flags = 0
            if 'content' in req:
                req.content = Bunch(req.content)
            print(req, file=sys.stderr)
            ROUTER[req.action, req.type](requester, req)
    requester.submit(RENDERER)
Ejemplo n.º 4
0
def render():
    # TODO: find board id?
    board_id = 1

    # Trigger a redraw.
    requester = Requester()
    with requester.requests():
        requester.update_board(board_id)
    requester.submit(RENDERER)

    # Get the image.
    img = RENDERER.get_png(1)

    # Return as PNG
    output = io.BytesIO(img)
    return send_file(output, mimetype='image/png', as_attachment=False)