Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

FastAPI send data without request from frontend

I have a frontend (react) which displays the current status of some hardware. The status of the hardware is periodically checked by some python script.

If the current status of the hardware changes i want to trigger some FastAPI call which sends the data from the backend to the frontend.

Currently i am periodically sending a request from the frontend to the backend and ask if the status of the hardware changed. But it feels not like the correct approach (Status of hardware can stay the same for a long time).

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Is there any design pattern or solution for my problem?

>Solution :

Such cases are solved by subscribing to events; there are two ways to constantly connect via webSocket, or use SSE (Server Sent Events).
Considering that it may be idle for a long time and the state will not change, I would advise using SSE

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading