diff --git a/flasky.py b/flasky.py index 5965fcc..024ee37 100644 --- a/flasky.py +++ b/flasky.py @@ -52,7 +52,7 @@ def crossdomain(origin=None, methods=None, headers=None, app = Flask(__name__) -client = MongoClient(**{'host': 'localhost', 'port': 27017}) +client = MongoClient(**{'host': '10.10.10.51', 'port': 27017}) db = client.showtimes miscObjHandler = lambda obj: ( @@ -67,6 +67,37 @@ def hello_world(): return 'This comes from Flask ^_^' +@app.route('/movies/', methods=['GET']) +@crossdomain(origin='*') +def movie_list(): + result = db.movies.find() + movies = [] + for i in result: + movies.append(i) + if len(movies) > 10: + break + json_dict = { + 'meta': { + 'total_count': len(movies) + }, + 'objects': movies + } + r = make_response(dumps(json_dict, default=miscObjHandler)) + r.mimetype = 'application/json' + return r + + +@app.route('/movie//', methods=['GET']) +@crossdomain(origin='*') +def movie_item(mid): + movie = db.movies.find_one({'id': int(mid)}) + if not movie: + movie = {} + r = make_response(dumps(movie, default=miscObjHandler)) + r.mimetype = 'application/json' + return r + + @app.route('/groups/', methods=['GET']) @crossdomain(origin='*') def groups(): @@ -77,7 +108,7 @@ def groups(): }, 'objects': known_groups } - r = make_response(dumps(json_dict)) + r = make_response(dumps(json_dict, default=miscObjHandler)) r.mimetype = 'application/json' return r diff --git a/settings.py b/settings.py index c78f46e..29c9f38 100644 --- a/settings.py +++ b/settings.py @@ -45,7 +45,7 @@ settings['xsrf_cookies'] = True settings['template_loader'] = tornado.template.Loader(TEMPLATE_ROOT) -SYSLOG_TAG = "stockintel" +SYSLOG_TAG = 'showtimes-serv' SYSLOG_FACILITY = logging.handlers.SysLogHandler.LOG_LOCAL2 # See PEP 391 and logconfig for formatting help. Each section of LOGGERS