From ace663341d1892eb594e0b7ea99bb35375f633ef Mon Sep 17 00:00:00 2001 From: assar Date: Mon, 5 Jun 2017 20:45:32 +0000 Subject: [PATCH] Fixed API calls address --- server.py | 7 ++++--- static/script.js | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/server.py b/server.py index f52cba8..fc789a0 100644 --- a/server.py +++ b/server.py @@ -11,11 +11,11 @@ db_engine = {} db_metadata = {} parts = {} -@app.route('/') +@app.route('/parts') def index(): return render_template('partsearch.html') -@app.route('/getpartinfo/') +@app.route('/parts/getpartinfo/') def get_part_info(partID): s = 'select * from parts where id = :id;' r = db_engine.execute(text(s), id=partID) @@ -25,9 +25,10 @@ def get_part_info(partID): r.close() return json.dumps(l[0]) -@app.route('/query//') +@app.route('/parts/query//') def query(filter, query): query = '%' + query + '%' + filter = int(filter) s = 'select * from parts where ' if filter & (1 << 0) != 0: s += 'LOWER(type) like LOWER(:name) or ' diff --git a/static/script.js b/static/script.js index b73b61a..e957799 100644 --- a/static/script.js +++ b/static/script.js @@ -26,7 +26,7 @@ $(document).ready(function() { filter += 16; if($('#notes').is(':checked')) filter += 32; - $.getJSON('http://127.0.0.1:5000/query/' + filter + '/' + query, function(data) { + $.getJSON('https://www.elab.kth.se/parts/query/' + filter + '/' + query, function(data) { var newResults = '
'; for(var i = 0; i < data.length; i++) { // Create new view for results newResults += '
'; @@ -60,7 +60,7 @@ $(document).ready(function() { newResults += '
'; if (data[i].datasheet != null) - newResults += ''; + newResults += ''; newResults += '
'; newResults += '' newResults += '
'; @@ -74,7 +74,7 @@ $(document).ready(function() { $('.results-row').on('click', function() { var partID = $(this).attr('part-id'); - $.getJSON('http://127.0.0.1:5000/getpartinfo/' + partID, function(data) { + $.getJSON('https://www.elab.kth.se/parts/getpartinfo/' + partID, function(data) { // TODO: Fill stuff with the fetched info }).fail(function() { console.log( "Fetching part info failed" );