0
votes

I've made an app using Flask, that has a backend process that is initiated by the user. When the user initiates the process, some data is sent to Flask via jQuery AJAX, which is then processed, and the results are returned. This process can take between a few seconds and up to around a minute, so I have a 'please wait' modal on the front end while waiting for the AJAX response from the backend.

Is there a way I can send interim data to the front end, to update the 'please wait' modal, while the backend process is doing its thing? The backed process performs iterations until it is satisfied. So ideally I would like to be able to display to the user how many iterations it has performed.

Initially I thought that there might be something within Flask's 'flash' message feature. But it seems that this relates more to redirects in a route, rather than AJAX calls to a route.

Any suggestions would be appreciated.

Cheers, Hugh

1

1 Answers

0
votes

Yes you can do it, but not with AJAX, becuse the HTTP comunication is only client to server, so you cant update asynchronously your clinent with HTTP, so you need to use other protocol. I highly recommend to use SocketIo, this protocol allows to you to send mensagens asynchronously from server to update your front, becuse this protocol persist the user in server. With this protocol(for example) you can make a chat room, like WhatsApp. for more information see Documentation SocketIo Flask Extension