in resources/code/scenario0/api/app.py [0:0]
def posts():
body = {}
key = "posts"
value = red.get(key)
if not value:
data = get_from_db(key)
keys = ['thread', 'text', 'user']
obj = dict(zip(keys, data[0]))
red.set(key, str(json.dumps(obj)))
body['source'] = 'database'
body['data'] = obj
else:
body['source'] = 'redis'
body['data'] = json.loads(value.decode('ascii'))
print("Body:")
print(body)
return jsonify(body), 200