|
@@ -10,20 +10,20 @@ def index(): |
|
|
return render_template("index.html") |
|
|
return render_template("index.html") |
|
|
|
|
|
|
|
|
@app.route("/graph", methods=["GET", "POST"]) |
|
|
@app.route("/graph", methods=["GET", "POST"]) |
|
|
def graph(page): |
|
|
|
|
|
|
|
|
def graph(): |
|
|
if request.method == 'POST': |
|
|
if request.method == 'POST': |
|
|
# Convert the data to a graph state |
|
|
# Convert the data to a graph state |
|
|
g = abp.GraphState() |
|
|
g = abp.GraphState() |
|
|
g.from_json(json.loads(data)) |
|
|
|
|
|
|
|
|
g.from_json(json.loads(request.data)) |
|
|
|
|
|
|
|
|
# Convert it back to JSON |
|
|
|
|
|
|
|
|
# Convert it back to JSON just for fun |
|
|
data = json.dumps(g.to_json(stringify=True)) |
|
|
data = json.dumps(g.to_json(stringify=True)) |
|
|
|
|
|
|
|
|
# Insert into the database |
|
|
# Insert into the database |
|
|
redis.execute_command("SET", "graph", data) |
|
|
redis.execute_command("SET", "graph", data) |
|
|
|
|
|
|
|
|
# Return success |
|
|
# Return success |
|
|
return "OK" |
|
|
|
|
|
|
|
|
return "Posted {} bytes OK".format(len(data)) |
|
|
|
|
|
|
|
|
else: |
|
|
else: |
|
|
# Get from the database |
|
|
# Get from the database |
|
|