Issue
this is a very general question. I was trying to look for something but here I might have a better start point. I am working with a python tool which is still on progress but the UI was done previously with PYQT5. What I wanted to do is creating some web front end (NextJs) and connecting with Django as backend and the calculations will be done on the local server we have.
What I wanted to check is how I can send real time updates to the front end about the process that is happening on the backend. lets say if there is a loop, so sending the 1/10,2/10 and so on. Is this a socket thing (?) like streaming messages while is inside the http request.
Thank you!
I am still on the looking for options stage, what I have though is that this can be possible with sockets and emit messages from the backend to the front.
Solution
You can use Channels to create a socket and a socket library like socket.io for NodeJS to form a connection to send/receive data.
Then just handle them in your NextJs frontend.
Since you are just sending and not receiving, a unidirectional method like SSE (server sent events) can be used too. However, it comes with it's own set of issues (see below).
How can I make SSE with Python (Django)?
I would recommend sticking with Channels or if you have the time, take a look at StreamingHttpResponse.
Answered By - waleed.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.