Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import Flask, render_template, request, jsonify
|
| 2 |
+
import json
|
| 3 |
+
|
| 4 |
+
app = Flask(__name__)
|
| 5 |
+
|
| 6 |
+
# Store nodes and connections in memory (replace with database for persistence)
|
| 7 |
+
nodes = []
|
| 8 |
+
connections = []
|
| 9 |
+
|
| 10 |
+
@app.route('/')
|
| 11 |
+
def index():
|
| 12 |
+
return render_template('index.html')
|
| 13 |
+
|
| 14 |
+
@app.route('/save_nodes', methods=['POST'])
|
| 15 |
+
def save_nodes():
|
| 16 |
+
global nodes, connections
|
| 17 |
+
data = request.get_json()
|
| 18 |
+
nodes = data.get('nodes', [])
|
| 19 |
+
connections = data.get('connections', [])
|
| 20 |
+
return jsonify({'status': 'success', 'nodes': nodes, 'connections': connections})
|
| 21 |
+
|
| 22 |
+
if __name__ == '__main__':
|
| 23 |
+
app.run(debug=True)
|