import json
from db import redis_client
from flask import jsonify, current_app
from flask_classful import FlaskView
class ConsumersView(FlaskView):
def get(self):
keys = redis_client.keys('consumer_*')
list_of_customer_ips = []
for key in keys:
info = json.loads((redis_client.get(key) or b"{}").decode('utf-8'))
list_of_customer_ips.append(info['ip'])
return jsonify(list_of_customer_ips)