This repository has been archived on 2020-09-24. You can view files and clone it, but cannot push or open issues or pull requests.
consumer-api/consumer_api/views/consumers_view.py

21 lines
458 B
Python
Raw Normal View History

2020-03-30 16:32:33 +02:00
import json
2020-03-30 17:00:59 +02:00
2020-03-30 16:32:33 +02:00
from db import redis_client
2020-04-01 00:31:13 +02:00
from flask import jsonify, current_app
2020-03-29 17:08:53 +02:00
from flask_classful import FlaskView
class ConsumersView(FlaskView):
def get(self):
2020-05-08 19:48:31 +02:00
keys = redis_client.keys('producer_*')
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)