V
V
VaniLuksh2020-04-19 17:55:13
Flask
VaniLuksh, 2020-04-19 17:55:13

How to implement a mechanism for receiving updates from the server?

There is an application that controls the device through the server. Management consists in passing the Json object to the device. Json object is formed from data in the database. The choice of transferred values ​​from the database is done by the application.
How to correctly implement sending a Json object to the device?
During the main operating time, the device should not receive any updates until a button is pressed in the application at one point.

So far, there are two implementation options:
1. The application makes changes to the database, and the web application constantly listens to the database for changes to a specific table and generates Json when it changes, and the device constantly polls the server application (Flask)
Cons: - constant connection of the web application to the database

2. The application itself pulls the necessary parameters from the database at the right time, generates json and sends a post request to the flask web application. Flask saves the json to a file, and the device knocks on that file and, when it comes up, loads the json.
Cons: -permanent creation of files
And related question
2.2 how is this implemented in flask? How to create a new route with a device token during a post request, and create a file using this route?

Ideally, I would like to do something in between:
The application sends a request with a device ID and a parameter by which to pull values ​​from the database, Flask gets the data from the database, generates json and creates a route through which the device receives json in response.
In this case, the technical implementation of what flask tools should be used is not clear and is it feasible in principle?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2020-04-25
@VaniLuksh

There is such a thing called API. Make two APIs on your Flask. API 1 will accept requests from the APP and store them somewhere. API 2 will accept requests from the DEVICE and give it data created based on what was received from the APP.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question