--- a/fetch.py +++ b/fetch.py @@ -10,7 +10,9 @@ import lxml.html import urllib2 import StringIO +import json + app = Flask(__name__) @@ -41,18 +43,35 @@ return jsonify(ret) +@app.route('/search', methods=['GET']) +def search(): + connection = pymongo.Connection() + db = connection['mural'] + collection = db['data'] + y = 0 + ret = {} + for i in collection.find(): + try: + if request.args['data'] in i['nodes']: + del(i['_id']) + ret[y] = i + y = y + 1 + except: + pass + return render_template('blank.html', content = ret) @app.route('/submit', methods=['POST']) def submit(): c = pymongo.Connection() db = c['mural'] coll = db['data'] + requestData = json.loads(request.form['data']) try: - for i in d: - coll.insert(request.args['data']) - response = make_response() - response.status = '200 OK' - response.status_code = 200 - return response + for i in requestData: + coll.insert(i) + response = make_response() + response.status = '200 OK' + response.status_code = 200 + return response except: response = make_response() response.status = "500" @@ -86,6 +105,7 @@ root.head.append(link) return lxml.html.tostring(root) + #Log the errors, don't depend on apache to log it for you. fil = FileHandler(os.path.join(os.path.dirname(__file__), 'logme'),mode='a') --- a/static/myVector.js +++ b/static/myVector.js @@ -60,7 +60,7 @@ }; function onFeatureSelect(feature) { - for(var i in ans.ans) + for(var i in ans.ans) { if(feature.geometry.bounds['left'] == ans.ans[i]['left'] && feature.geometry.bounds['right'] == ans.ans[i]['right'] && feature.geometry.bounds['top'] == ans.ans[i]['top'] && feature.geometry.bounds['bottom'] == ans.ans[i]['bottom']) { @@ -244,7 +244,7 @@ map.addLayers([box2, box3]); selectControl = new OpenLayers.Control.SelectFeature(box3, - {onSelect: onFeatureSelect}); + {hover:true, clickout: true, onSelect: onFeatureSelect}); drawControls = { box : new OpenLayers.Control.DrawFeature(boxes,