2014-03-19 09:12:47 +00:00
|
|
|
from flask import Flask, render_template, request
|
2014-05-28 16:48:46 +00:00
|
|
|
from graphData import insert_graph_data
|
2014-03-19 09:12:47 +00:00
|
|
|
|
|
|
|
app = Flask(__name__)
|
2014-05-30 14:34:00 +00:00
|
|
|
app.config.from_pyfile('web_config.cfg')
|
2014-03-19 09:12:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
@app.context_processor
|
|
|
|
def add_ip():
|
|
|
|
return dict(ip=request.environ['REMOTE_ADDR'])
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/')
|
|
|
|
@app.route('/network')
|
|
|
|
def page_network():
|
2014-05-13 22:36:55 +00:00
|
|
|
return render_template('network.html', page='network')
|
|
|
|
|
|
|
|
@app.route('/about')
|
|
|
|
def page_about():
|
|
|
|
return render_template('about.html', page='about')
|
2014-03-19 09:12:47 +00:00
|
|
|
|
2014-05-28 16:48:46 +00:00
|
|
|
@app.route('/sendGraph', methods=['POST'])
|
|
|
|
def page_sendGraph():
|
2014-05-30 14:34:00 +00:00
|
|
|
print "Receiving graph from %s" % (request.remote_addr)
|
|
|
|
|
2014-05-28 16:48:46 +00:00
|
|
|
data = request.form['data']
|
2014-05-30 14:34:00 +00:00
|
|
|
ret = insert_graph_data(app.config, data)
|
2014-05-28 16:48:46 +00:00
|
|
|
if ret:
|
|
|
|
return 'OK'
|
|
|
|
else:
|
|
|
|
return 'FAIL'
|
2014-03-19 09:12:47 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
app.run(host='::')
|