Skip to content
Snippets Groups Projects
Commit e1906d0f authored by MikelLiza's avatar MikelLiza
Browse files

changed app.py

Now can search for name of show in list without returning all
parent 1bc5cc4e
No related branches found
No related tags found
No related merge requests found
......@@ -114,17 +114,20 @@ class Recommendations(Resource):
return jsonify(api_result)
@api.route('/api/shows')
@api.route('/api/shows/<string:tv_series>')
@api.doc()
class SeriesNames(Resource):
def get(self):
def get(self, tv_series):
# get entire collection as a list
collection_li = list(collection.find({}, {"_id": 0}))
# select only the names of the tv series
series_names = [i['name'] for i in collection_li]
if len(tv_series) < 3:
return jsonify({'names': []})
else:
series_names = [i['name'] for i in collection_li if tv_series.lower() in i['name'].lower()]
# return as a dict
result = {'names': series_names}
return jsonify(result)
result = {'names': series_names}
return jsonify(result)
@api.route('/api/info/<string:tv_series>')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment