miguelgrinberg / turbo-flask

Integration of Hotwire's Turbo library with Flask.
MIT License
301 stars 35 forks source link

turbo.can_stream() is always False #3

Closed janpeterka closed 3 years ago

janpeterka commented 3 years ago

Hi, I would love to use Turbo in my Flask app, so thanks for working on this! I don't know if it should work, but it mostly doesn't for me. If I check for turbo.can_stream(), I always get False. I I return without checking, sometimes it works, and sometimes it doesn't. Thanks for your help!

miguelgrinberg commented 3 years ago

The can_stream method returns True only when the client explicitly indicates that it can accept streams. If you look at their documentation, the only time streams are supported in HTTP is in the response to a form submission via POST request.

The other option for streams is to use the push mode, which works over a WebSocket connection outside of the HTTP request/response cycle. This is not currently supported in this package.

janpeterka commented 3 years ago

oh, thank you for explanation. any plan on adding Websocket Stream support? :)

miguelgrinberg commented 3 years ago

I'm thinking about it. The problem is that the WebSocket options for Flask all introduce many complications, like the need to use gevent.