FastAPI send metadata when sending bytes in a websocket

Viewed 25

I'm building a small comic reading API in which I send the comic pages as bytes page by pages in a stream (that can be controlled to read the next of previous one).

To avoid any confusion in some cases (like next page is requested but last page has been reached) I'd like to send the page number as metadata with the bytes I send.

Not sure how to do that, I could send a text message with a JSON object before or after the bytes, but in case of sudden disconnection I feel like this could cause sync issues.

0 Answers
Related