V
V
Vova3162021-11-30 11:24:38
Flask
Vova316, 2021-11-30 11:24:38

How can I set the date on the Flask server to be the same as the date on the client in the browser (no internet)?

Hello.
There is a Flask server running on a RaspberryPi.
This server keeps logs of operator actions in files. But the date and time in the logs are incorrect, due to the fact that the RaspberryPi loses the correct time values ​​after turning it off / on.
Sometimes a laptop is connected to the server via a local Ethernet to see the logs. Those. in fact, it turns out a local wired network without access to the Internet. Those. a network with two devices: RaspberyyPi (server) and a connected laptop (client).
At this point, it is possible to update the time through the client's browser! Indeed, in a laptop, time is clearly more reliable!
What should be included in the log page? What script?
How to get this data correctly on the server side?
By the way, some pages already have scripts (updating the screen, updating the log file, accepting form data, etc.).
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
paran0id, 2021-11-30
@paran0id

Not exactly what you asked for, but it's worth setting up a precise time service on the raspberry. I recommend chrony. If it does not have access to exact time servers at all, time can be obtained via gps using such a module.

G
GavriKos, 2021-11-30
@GavriKos

Solution "through one place". Let the server both store and store time in its frame of reference. And the client, when accessing the page with logs, sends its CURRENT time as a parameter. Further, the server's task is simple - to calculate the delta of the transmitted current and its current, and correct (I would correct only the output, and not the logs themselves) all timestamps for it.
You understand the nuance - different clients will receive different log times if their local time is different. But this can also be solved by similar principles

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question