How to send a message notification to the front end by flask

for example, there is a current user @ someone, and then send a message notification to the user"s page to tell him there is a new message. What should I do, please? What I use is the separation of the front and back end of flask, and the front end is vue,. Currently, login verification is in the front end, and the back end does not record whether the user logs in or not.

Mar.03,2022

it is impossible to use http to push messages from the server to the client
1. The client constantly requests an interface of the server to get the latest messages
2. Both client and server use websocket
and other polling methods are similar to 1


can be used using Http and websocket. Http can simulate real-time message Synchronize by using http stream or long polling and short polling. The best way is to use webscoket protocol to interact. Because Http is one-way communication, only websocket is two-way communication


learn about Server-Send Event
allows the server to push messages to the client one-way.


use websocet. This is an article I wrote. You can take a look at 's CRUD operation based on flask-socketio

.
Menu