summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Bringemo <maxbr167@student.liu.se>2020-12-03 21:23:09 +0100
committerMax Bringemo <maxbr167@student.liu.se>2020-12-03 21:23:09 +0100
commit0d0f1221d854be9210b1601460608e8c5f236204 (patch)
tree4759912c83afdb9884e22b16e419fb0ab97d1349
parentf514c5fc686568f6a3a17ee6874c0a6973cd2a54 (diff)
downloadtdde25-0d0f1221d854be9210b1601460608e8c5f236204.tar.gz
added @get for showing favicon on web page
-rw-r--r--server.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/server.py b/server.py
index 6a93018..5323bf7 100644
--- a/server.py
+++ b/server.py
@@ -4,7 +4,6 @@ import algorithms
import store
from lib import run_server, get, post, read_html
-
nodes = None
@@ -18,16 +17,32 @@ def index():
@get('/show-area')
def show_area():
rect = dict()
- for (k, node) in enumerate(store.select_nodes_in_rectangle(nodes, 58.3984, 58.3990, 15.5733, 15.576)):
+ for (k, node) in enumerate(
+ store.select_nodes_in_rectangle(nodes, 58.3984, 58.3990, 15.5733,
+ 15.576)):
rect[node.id] = node.coord_tuple()
return json.dumps(rect)
+@get('/favicon.ico')
+def favicon():
+ with open("data/favicon.ico", "rb") as \
+ image:
+ f = image.read()
+ image_bytes = bytearray(f)
+
+ return image_bytes
+
+
@post('/shortest-path')
def shortest_path(body):
body = json.loads(body)
- source_id = algorithms.get_closest_node_id(nodes, store.Node(-1, body['lat1'], body['lng1']))
- target_id = algorithms.get_closest_node_id(nodes, store.Node(-1, body['lat2'], body['lng2']))
+ source_id = algorithms.get_closest_node_id(nodes,
+ store.Node(-1, body['lat1'],
+ body['lng1']))
+ target_id = algorithms.get_closest_node_id(nodes,
+ store.Node(-1, body['lat2'],
+ body['lng2']))
path = algorithms.find_shortest_path(nodes, source_id, target_id)
print(path)