From e5e86696635aa708d505013cd42e61fa1ec44cf5 Mon Sep 17 00:00:00 2001 From: Jacob Date: Tue, 26 Mar 2019 22:52:57 +0100 Subject: [PATCH] Connect website to shortestPath endpoint --- magazine/__pycache__/views.cpython-37.pyc | Bin 1614 -> 1622 bytes magazine/static/magazine/forklift.js | 6 ++--- magazine/static/magazine/sketch.js | 26 ++++++++++++++++++---- magazine/templates/magazine/index.html | 4 +++- magazine/views.py | 3 ++- 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/magazine/__pycache__/views.cpython-37.pyc b/magazine/__pycache__/views.cpython-37.pyc index 0013882f6fad97bdbd1979d6564ecd13a7e8dd24..71fc264a14e36d21c7e5b1cd636371466d4bbb13 100644 GIT binary patch delta 426 zcmXw0Jxc>Y5S`h*OYSz=vooA1ViQecAvQv=kQ8F6MG%ul4n+g%9Vc8dYYG*tMAS&QD12SDJmClJZ=N|d70FZw~7bcZF@557Nbj}NgtvKvN~yU zdXgvHry%#ZR)@?7^DxnjzQcH(I|UK&@ve(Gy<$i9FSj8`eKy^Yso8;sZ+GP>&e%73 skF$2qS*-oAG*sd<@kv4dmwT2Rouu}`dG|Mq?+^+-d+e@Z$v(QHUr|46MgRZ+ delta 361 zcmX9)u}T9$5S`h*Gj~hwtfCx((ZWb9>?5hh5uOsDabJt~I^d?*y|> z0wa%aZp2d_L08# { + path = response.split('').map(Number); + forklift.currentTarget = path[0]; + forklift.setPath(path); + going = true; + }, + error => { + console.log(error); + } + ); } function createMagazineLayout() { diff --git a/magazine/templates/magazine/index.html b/magazine/templates/magazine/index.html index 6136c2a..edd6aab 100644 --- a/magazine/templates/magazine/index.html +++ b/magazine/templates/magazine/index.html @@ -1,7 +1,7 @@ {% load static %} - + @@ -59,6 +59,8 @@ Hard Soft + +
diff --git a/magazine/views.py b/magazine/views.py index 73d1cb9..30bba36 100644 --- a/magazine/views.py +++ b/magazine/views.py @@ -20,6 +20,7 @@ def classify(request): @csrf_exempt def shortestPath(request): loaded_request = json.load(request) + print(loaded_request) graph = loaded_request["graph"] graph = {int(k): v for k, v in graph.items()} @@ -55,7 +56,7 @@ def shortestPath(request): for node in graph: current = node - p = [current + 1] + p = [current] while current != start_node: p.append(predecessor[current]) current = predecessor[current]