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
Füleki Fábián 67d71fa43e
Some checks failed
continuous-integration/drone/push Build is failing
Fixed customers endpoint
2020-05-08 19:48:31 +02:00

21 lines
458 B
Python

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('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)