Commit 438fa91c6424af5dc156ea4bbab2bb93d0ae88bf
- Diff rendering mode:
- inline
- side by side
fetch.py
(26 / 6)
  | |||
10 | 10 | import lxml.html | |
11 | 11 | import urllib2 | |
12 | 12 | import StringIO | |
13 | import json | ||
13 | 14 | ||
15 | |||
14 | 16 | app = Flask(__name__) | |
15 | 17 | ||
16 | 18 | ||
… | … | ||
43 | 43 | return jsonify(ret) | |
44 | 44 | ||
45 | 45 | ||
46 | @app.route('/search', methods=['GET']) | ||
47 | def search(): | ||
48 | connection = pymongo.Connection() | ||
49 | db = connection['mural'] | ||
50 | collection = db['data'] | ||
51 | y = 0 | ||
52 | ret = {} | ||
53 | for i in collection.find(): | ||
54 | try: | ||
55 | if request.args['data'] in i['nodes']: | ||
56 | del(i['_id']) | ||
57 | ret[y] = i | ||
58 | y = y + 1 | ||
59 | except: | ||
60 | pass | ||
61 | return render_template('blank.html', content = ret) | ||
46 | 62 | @app.route('/submit', methods=['POST']) | |
47 | 63 | def submit(): | |
48 | 64 | c = pymongo.Connection() | |
49 | 65 | db = c['mural'] | |
50 | 66 | coll = db['data'] | |
67 | requestData = json.loads(request.form['data']) | ||
51 | 68 | try: | |
52 | for i in d: | ||
53 | coll.insert(request.args['data']) | ||
54 | response = make_response() | ||
55 | response.status = '200 OK' | ||
56 | response.status_code = 200 | ||
57 | return response | ||
69 | for i in requestData: | ||
70 | coll.insert(i) | ||
71 | response = make_response() | ||
72 | response.status = '200 OK' | ||
73 | response.status_code = 200 | ||
74 | return response | ||
58 | 75 | except: | |
59 | 76 | response = make_response() | |
60 | 77 | response.status = "500" | |
… | … | ||
105 | 105 | root.head.append(link) | |
106 | 106 | ||
107 | 107 | return lxml.html.tostring(root) | |
108 | |||
108 | 109 | ||
109 | 110 | #Log the errors, don't depend on apache to log it for you. | |
110 | 111 | fil = FileHandler(os.path.join(os.path.dirname(__file__), 'logme'),mode='a') |
static/myVector.js
(2 / 2)
  | |||
60 | 60 | }; | |
61 | 61 | function onFeatureSelect(feature) | |
62 | 62 | { | |
63 | for(var i in ans.ans) | ||
63 | for(var i in ans.ans) | ||
64 | 64 | { | |
65 | 65 | 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']) | |
66 | 66 | { | |
… | … | ||
244 | 244 | map.addLayers([box2, box3]); | |
245 | 245 | ||
246 | 246 | selectControl = new OpenLayers.Control.SelectFeature(box3, | |
247 | {onSelect: onFeatureSelect}); | ||
247 | {hover:true, clickout: true, onSelect: onFeatureSelect}); | ||
248 | 248 | ||
249 | 249 | drawControls = { | |
250 | 250 | box : new OpenLayers.Control.DrawFeature(boxes, |