def edit(uid): elements = ['category','entity','winner','year'] for i in request.args.keys(): if i in elements: param = request.args.get(i).replace("_", " ") rd.hset(uid, i, param) return jsonify(rd.hgetall(uid))
def showyearcat(year,category): filmlist = [] category = category.replace("_", " ") for key in rd.keys(): if rd.hget(key,'year') == year and category == rd.hget(key,'category'): filmlist.append(rd.hgetall(key)) return jsonify(filmlist)
def showname(entity): filmlist = [] entity = entity.replace("_", " ") for key in rd.keys(): if entity == rd.hget(key,'entity'): filmlist.append(rd.hgetall(key)) return jsonify(filmlist)
def create(): category = request.args.get('category').replace("_", " ") entity = request.args.get('entity').replace("_", " ") winner = request.args.get('winner').replace("_", " ") year = request.args.get('year').replace("_", " ") uid = str(uuid.uuid4()) rd.hmset(uid, {"category": category, "entity": entity, "winner": winner, "year": year, "uid": uid}) return jsonify(rd.hgetall(uid))
def showrange(): start = request.args.get('start') end = request.args.get('end') rangelist = [] for key in rd.keys(): year = rd.hget(key,'year') if year >= start and year <= end: rangelist.append(rd.hgetall(key)) return "\n".join([str(x) for x in rangelist])
def showuid(uid): return jsonify(rd.hgetall(uid))
def showyear(year): filmlist = [] for key in rd.keys(): if rd.hget(key,'year') == year: filmlist.append(rd.hgetall(key)) return "\n".join([str(x) for x in filmlist])
def deleteuid(uid): gone = rd.hgetall(uid) rd.delete(uid) gone['status'] = "DELETED" return jsonify(gone)