summaryrefslogtreecommitdiff
path: root/lib/api/stitch_plan.py
diff options
context:
space:
mode:
authorLex Neva <lexelby@users.noreply.github.com>2020-04-28 12:34:05 -0400
committerGitHub <noreply@github.com>2020-04-28 18:34:05 +0200
commitcb2b4e3522cb7f426ba5ad3e68deb9e6ccc581ec (patch)
tree2a2f38823c3c9f0b5439ce2aa7c9040299109292 /lib/api/stitch_plan.py
parenteb526927e16954390d06929535d6f5c3766b5f6c (diff)
electron simulator (#531)
Diffstat (limited to 'lib/api/stitch_plan.py')
-rw-r--r--lib/api/stitch_plan.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/api/stitch_plan.py b/lib/api/stitch_plan.py
new file mode 100644
index 00000000..fd6bf9c9
--- /dev/null
+++ b/lib/api/stitch_plan.py
@@ -0,0 +1,17 @@
+from flask import Blueprint, g, jsonify
+
+from ..stitch_plan import patches_to_stitch_plan
+
+
+stitch_plan = Blueprint('stitch_plan', __name__)
+
+
+@stitch_plan.route('')
+def get_stitch_plan():
+ if not g.extension.get_elements():
+ return dict(colors=[], stitch_blocks=[], commands=[])
+
+ patches = g.extension.elements_to_patches(g.extension.elements)
+ stitch_plan = patches_to_stitch_plan(patches)
+
+ return jsonify(stitch_plan)