Commit 7d19e0d1903f2842ebe04607c45ef1b8dd4ec2d0
Fixing API
- /search will accept an array of keywords and run a search.
| | | | 50 | collection = db['data'] | 50 | collection = db['data'] |
---|
51 | y = 0 | 51 | y = 0 |
---|
52 | ret = {} | 52 | ret = {} |
---|
| | 53 | keywords_dict = json.loads(request.args['data']) |
---|
| | 54 | keywords = json.loads(keywords_dict)['data'] |
---|
53 | for i in collection.find(): | 55 | for i in collection.find(): |
---|
54 | try: | | try: |
---|
55 | if request.args['data'] in i['nodes']: | | if request.args['data'] in i['nodes']: |
---|
56 | del(i['_id']) | | del(i['_id']) |
---|
57 | ret[y] = i | | ret[y] = i |
---|
58 | y = y + 1 | | y = y + 1 |
---|
59 | except: | | except: |
---|
60 | pass | | pass |
---|
| | 56 | for keyword in keywords: | | | 57 | print keyword |
---|
| | 58 | try: |
---|
| | 59 | if keyword in i['nodes']: |
---|
| | 60 | del(i['_id']) |
---|
| | 61 | ret[y] = i |
---|
| | 62 | y = y + 1 |
---|
| | 63 | except: |
---|
| | 64 | pass |
---|
61 | return render_template('blank.html', content = ret) | 65 | return render_template('blank.html', content = ret) |
---|
| | 66 | |
---|
| | 67 | |
---|
62 | @app.route('/submit', methods=['POST']) | 68 | @app.route('/submit', methods=['POST']) |
---|
63 | def submit(): | 69 | def submit(): |
---|
64 | c = pymongo.Connection() | 70 | c = pymongo.Connection() |
---|