Commit 5c5d01a9b21e182ca7e61d157f6c03b91953e503
Fixing fetch.py
- Added missing import and a return statement
| | | | 6 | import logging | 6 | import logging |
---|
7 | from logging import FileHandler | 7 | from logging import FileHandler |
---|
8 | import pymongo | 8 | import pymongo |
---|
| | 9 | import os |
---|
9 | | 10 | |
---|
10 | | | |
---|
11 | app = Flask(__name__) | 11 | app = Flask(__name__) |
---|
12 | | 12 | |
---|
13 | @app.route('/', methods=['GET']) | 13 | @app.route('/', methods=['GET']) |
---|
… | | … | |
---|
24 | collection = db['data'] | 24 | collection = db['data'] |
---|
25 | ret = {} | 25 | ret = {} |
---|
26 | x = 0 | 26 | x = 0 |
---|
27 | for i in collection.find({'url':request.args['url']}): | | for i in collection.find({'url':request.args['url']}): |
---|
| | 27 | resource = "default" | | | 28 | if request.args.has_key('res'): |
---|
| | 29 | resource = request.args['res'] |
---|
| | 30 | for i in collection.find({'res':resource}): |
---|
28 | del(i['_id']) | 31 | del(i['_id']) |
---|
29 | ret[x] = i | 32 | ret[x] = i |
---|
30 | x = x + 1 | 33 | x = x + 1 |
---|
31 | jsonify(ret) | | jsonify(ret) |
---|
| | 34 | return jsonify(ret) | 32 | | 35 | |
---|
33 | | 36 | |
---|
34 | #Log the errors, don't depend on apache to log it for you. | 37 | #Log the errors, don't depend on apache to log it for you. |
---|