fix: 前端时钟校准问题

This commit is contained in:
2026-04-18 17:01:10 +08:00
parent f49582536b
commit 9c0e879aec
6 changed files with 235 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
from __future__ import annotations
import json
import time
from django.views.decorators.csrf import csrf_exempt
from django.http import HttpResponse, StreamingHttpResponse
@@ -31,6 +32,20 @@ def network_latest(request):
return Response(network_service.get_latest())
@api_view(["GET"])
def clock_calibration(request):
server_received_unix_ns = time.time_ns()
server_sent_unix_ns = time.time_ns()
response = Response(
{
"server_received_unix_ms": round(server_received_unix_ns / 1_000_000.0, 3),
"server_sent_unix_ms": round(server_sent_unix_ns / 1_000_000.0, 3),
}
)
response["Cache-Control"] = "no-store, no-cache, must-revalidate, max-age=0"
return response
@api_view(["GET"])
def video_status(request):
return Response(video_service.get_status())