Skip to content Skip to sidebar Skip to footer

Real Time Data With Flask?

Hello I am trying to build an application using flask and the twitter stream API. What I would eventually like to do is update a map in real time with tweets based on their attache

Solution 1:

There are a couple things you can do. The first is using ajax, where you just set an interval for each request to the REST api. The other option would be to use websockets. Here is some documentation to implement websockets with python https://ws4py.readthedocs.org/en/latest/. Using ajax would be the easier solution, but websockets is a better one.

If you are unfamiliar with websockets, the idea is that a server can send a message to the client. So when someone goes to your website a connection opens between the client and server. On the server side when you stream some data with a geolocation and you want to display it on the map, the server can send a message to the client with the data. That way, everything displayed on the map is in real time and you dont have any more requests than necessary.

Post a Comment for "Real Time Data With Flask?"