From d31799b3aac72ba6cecc09708be0365429082e6f Mon Sep 17 00:00:00 2001 From: Marek Baczynski Date: Sun, 11 Nov 2018 20:05:55 +0100 Subject: [PATCH] endpoint for listing locations in a given container --- parts/server.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/parts/server.py b/parts/server.py index 524bccd..f62fcc0 100644 --- a/parts/server.py +++ b/parts/server.py @@ -55,6 +55,16 @@ def index(): r.close() return render_template('partsearch.html', locations=locations) +@app.route('/parts/getlocationsInContainer/') +def get_locations_in_container(containerID): + s = 'select id, name from locations where container_id = :id order by name;' + r = db_engine.execute(text(s), id=containerID) + l={} + for row in r: + l[row[0]]= row[1]; + r.close() + return json.dumps(l) + @app.route('/parts/getlocationURL/') def get_locationURL(locationID): s = 'select map from locations where id = :id;'