mirror of
https://github.com/cwinfo/yggdrasil-map
synced 2025-06-26 12:49:23 +00:00
Graph sending script
This commit is contained in:
9
web/graphData.py
Normal file
9
web/graphData.py
Normal file
@ -0,0 +1,9 @@
|
||||
import json
|
||||
|
||||
def insert_graph_data(json_str):
|
||||
try:
|
||||
graph_data = json.loads(json_str)
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
return True
|
@ -1,4 +1,5 @@
|
||||
from flask import Flask, render_template, request
|
||||
from graphData import insert_graph_data
|
||||
|
||||
app = Flask(__name__)
|
||||
app.debug = False
|
||||
@ -18,6 +19,14 @@ def page_network():
|
||||
def page_about():
|
||||
return render_template('about.html', page='about')
|
||||
|
||||
@app.route('/sendGraph', methods=['POST'])
|
||||
def page_sendGraph():
|
||||
data = request.form['data']
|
||||
ret = insert_graph_data(data)
|
||||
if ret:
|
||||
return 'OK'
|
||||
else:
|
||||
return 'FAIL'
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host='::')
|
||||
|
Reference in New Issue
Block a user