5
0
mirror of https://github.com/cwinfo/yggdrasil-map synced 2024-11-10 03:30:27 +00:00
yggdrasil-map/web/web.py

35 lines
760 B
Python
Raw Normal View History

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__)
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():
print "Receiving graph from %s" % (request.remote_addr)
2014-05-28 16:48:46 +00:00
data = request.form['data']
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__':
app.run(host='::')