Exemplo n.º 1
0
def load_config(pth):
    if '.' in pth:
        (_id, ext) = pth.split('.')
    else:
        _id = pth
        ext = None

    graph = Graph()
    graph.id = _id

    try:
        config = graph.config
    except AttributeError:
        abort(500)

    if ext == 'png':
        image = graph.graph()
        if image:
            return Response(image, mimetype='image/png')
        else:
            abort(404)

    return render_template('index.html',
                           graphite_host=graphite_host,
                           graph=dumps(config))
Exemplo n.º 2
0
def load_blob(_id):
    graph = Graph()
    graph.id = _id
    image = graph.blob

    if image:
        return Response(image, mimetype='image/png')
    else:
        abort(500)
Exemplo n.º 3
0
def save_snapshot():
    url = request.form.get('url', None)
    if not url:
        abort(400)

    graph = Graph()
    _id = graph.snapshot(url)
    if not _id:
        abort(500)
    return jsonify(message=_id)
Exemplo n.º 4
0
def save_config():
    config = request.form.get('config', None)
    if not config:
        abort(400)

    graph = Graph()

    try:
        graph.config = config
    except AttributeError:
        abort(500)

    if not graph.id:
        abort(500)

    return jsonify(message=graph.id)