| from flask import Flask, jsonify, send_from_directory |
|
|
| app = Flask(__name__, static_folder='build', static_url_path='') |
|
|
| @app.route('/api/data') |
| def get_data(): |
| data = { |
| "nodes": [ |
| {"id": "1", "data": {"label": "Node 1"}, "position": {"x": 100, "y": 100}}, |
| {"id": "2", "data": {"label": "Node 2"}, "position": {"x": 300, "y": 200}} |
| ], |
| "edges": [ |
| {"id": "e1-2", "source": "1", "target": "2"} |
| ] |
| } |
| return jsonify(data) |
|
|
| @app.route('/') |
| def serve_index(): |
| return send_from_directory(app.static_folder, 'index.html') |
|
|
| if __name__ == "__main__": |
| app.run(host="0.0.0.0", port=7860) |
|
|