← Back to team overview

graphite-dev team mailing list archive

Re: [Question #213436]: http post interface for graphite / carbon

 

Question #213436 on Graphite changed:
https://answers.launchpad.net/graphite/+question/213436

nobody posted a new comment:
Here is a simplest example for http proxy for carbon:

#!/usr/bin/python
from flask import Flask, request, abort
from flup.server.fcgi import WSGIServer
import socket

app = Flask(__name__)
app.config.from_object(__name__)
HOST = 'localhost'
PORT = 2013

@app.route('/upload', methods = ['POST'])
def upload():
    if request.method == 'POST':
        data = request.form['data']
        if data:
            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            s.settimeout(1)
            s.connect((HOST,PORT))
            s.sendall(data)
            s.sendall("\n")
            s.close()
            app.logger.debug('sent %s to %s' % (data,HOST))
        else:
            app.logger.error("no data :(")
    return "OK"

if __name__ == '__main__':
    app.debug = True
    app.run()

-- 
You received this question notification because you are a member of
graphite-dev, which is an answer contact for Graphite.