from flask import Flask, request, redirect, url_for, make_response, render_template, Markup, send_from_directory, send_file from flask_redis import FlaskRedis import json, abp app = Flask(__name__) redis = FlaskRedis(app) @app.route("/") def index(): return render_template("index.html") @app.route("/graph", methods=["GET", "POST"]) def graph(page): if request.method == 'POST': # Convert the data to a graph state g = abp.GraphState() g.from_json(json.loads(data)) # Convert it back to JSON data = json.dumps(g.to_json(stringify=True)) # Insert into the database redis.execute_command("SET", "graph", data) # Return success return "OK" else: # Get from the database return redis.get("graph")