2

I'm having a problem in implementing an application using the Flask framework to send real-time data to a client browser. It will be streaming tweet user info to a client, using the twitter Streaming API(tweepy). Tweet information is also stored into a mongo DB, for future retrieval.

I assume this has to involve long-polling/ server side events(SSEs), which Flask doesn't seem to handle with ease. Juggernaut doesn't do it and is now deprecated in favour of SSEs.

Would Tornado be more suitable if I wanted to send real-time data to a client, or are there more appropriate web frameworks.

I am fairly new to python and it's the first time I'm trying to do this.

Thanks

2 Answers 2

1

Flask can handle long-polling or events, the main implementation problem is the WSGI server. Here's an example with gevent and websockets: https://gist.github.com/1185629

Sign up to request clarification or add additional context in comments.

4 Comments

When I try the example in the link it gives me a 500 error.
Possible. The example i linked was just to illustrate how Flask can handle long polling. That GIST was made a year ago, it might not be compatible with your flask version. All that said, it's up to the WSGI server to support long polling / event, not flask.
Ok, would it be easier to use tornado which seems to support pushing data from server to client at the outset?
Another example of Flask, gevent, and gevent-websocket https://bitbucket.org/jeunice/flask-ws-example. Not a Web Sockets masterpiece, as it tries to remain parallel and comparable to my similar example of Flask and long-polling. But it gives the general idea, with a few refinements.
0

You can use websocket witn socket.io and look ath this post about python client library.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.