|
|
|
@ -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/<mid>/', 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 |
|
|
|
|
|
|
|
|
|