How to display RabbitMQ messages dynamically in HTML (frontend)?
I try to pass variables coming from RabbitMQ and display them in the frontend in my Django project. I am using HTML. I can send the messages and receive them in backend and I can display them in console. But I try to display them in the frontend. How can I do that?
functions.py
def send_message(text):
credentials = pika.PlainCredentials('username', 'pass')
parameters = pika.ConnectionParameters('ip',
5672,
'/',
credentials)
connection = pika.BlockingConnection(parameters)
channel = connection.channel()
channel.queue_declare(queue='hello')
channel.basic_publish(exchange='', routing_key='hello', body=text)
print(" [x] Sent 'Hello World!'")
connection.close()
class my_class():
def __init__(self, ...)
send_message("Downloading...")
self.download_all()
...
def download_all(self, ...)
...
var = ""
arr_length = len(scans)
for s in scans:
i = 1
var = "Progress = " + str(i) + "/" + str(arr_length)
send_message(var)
i += 1
views.py
def setup_wizard(request):
functions.my_class(...)
return render(request, 'setup_wizard.html', context)
Note: Celery don't work for us.