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():
|
2015-07-26 17:08:51 +00:00
|
|
|
ip = request.headers['x-real-ip']
|
|
|
|
if ip == '10.18.3.20':
|
|
|
|
ip = request.headers['x-atomshare-real-ip']
|
|
|
|
return dict(ip=ip)
|
2014-03-19 09:12:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
@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-06-04 18:41:33 +00:00
|
|
|
if ret == None:
|
2014-05-28 16:48:46 +00:00
|
|
|
return 'OK'
|
|
|
|
else:
|
2014-06-04 18:41:33 +00:00
|
|
|
return 'Error: %s' % ret
|
2014-03-19 09:12:47 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2015-07-26 17:08:51 +00:00
|
|
|
app.run(host='localhost', port=3000)
|