0

I'm relatively new to REST API and web development in general. I'm looking for options for a client GET request to receive data incrementally/streaming until all data is sent with some criterias:

  • Has to be async (need to use twisted/klein as framework), here's only with Flask as reference.
  • Need to render server-side (next.js has option with socket.io in here with react -> which is the frontend I use), I know it's unrelated, but it's nice to have reading materials like that so I can glue/frankensteinize components together.

my model

From the server (python) It has to be yielded from generator object, right? what confusing me is the underlying options/quirks between websocket, long polling, and server-sent-events, not to mention frameworks like autobahn, WAMP and service like pushpin and crossbar.io which I think is overkill for my case.

The reason I'm mentioning them all is to ask for best practice in using them with their many ways of implementation (phew..). It's a bit overwhelming without enough experience.

At the core level (http headers/protocols/curl), what need to be actually set on the client and server given my scenario? And does long polling sounds like the solution? Does async is a good idea?

Reference reading:

What are Long-Polling, Websockets, Server-Sent Events (SSE) and Comet?

My Understanding of HTTP Polling, Long Polling, HTTP Streaming and WebSockets

http://blog.fanout.io/2016/11/21/moving-from-polling-to-long-polling/

https://blog.al4.co.nz/2016/01/streaming-json-with-flask/

TL;DR: Best practice of long polling implementation in asynchronous python webserver.

Ardhi
  • 2,855
  • 1
  • 22
  • 31
  • Nevow Athena (based on Twisted Web) uses essentially the low-level technique you describe here to provide a high-level bi-directional symmetric RPC system. It's a fairly obscure library, though, and you may have difficulty finding a supporting community for it. – Jean-Paul Calderone Nov 12 '18 at 12:41
  • Thank you, I'll take a look at it, it's in the documentation the whole time (twisted web), should've looked there first. – Ardhi Nov 13 '18 at 00:20

0 Answers0