@@ -13,15 +13,16 @@ class SessionView(View):
13
13
def get (self , request , session_id = 0 , * args , ** kwargs ):
14
14
df = self .telemetry_loader .get_session_df (session_id )
15
15
16
+ if df is None :
17
+ return JsonResponse ({"error" : f"Session with ID { session_id } does not exist" }, status = 404 )
18
+
16
19
# Compression:
17
20
# Compress the JSON response. Django can be configured to gzip responses, which can significantly reduce the response size.
18
21
# Make sure your frontend can handle the decompression, which is typically handled automatically by modern browsers.
19
22
20
23
# render the dataframe as json
21
24
df_json = df .to_json (orient = "split" , date_format = "iso" )
22
-
23
25
df_dict = json .loads (df_json )
24
-
25
26
return JsonResponse (df_dict , safe = False )
26
27
27
28
@@ -32,8 +33,9 @@ class LapView(View):
32
33
def get (self , request , lap_id = 0 , * args , ** kwargs ):
33
34
df = self .telemetry_loader .get_lap_df (lap_id )
34
35
35
- df_json = df .to_json (orient = "split" , date_format = "iso" )
36
+ if df is None :
37
+ return JsonResponse ({"error" : f"Lap with ID { lap_id } does not exist" }, status = 404 )
36
38
39
+ df_json = df .to_json (orient = "split" , date_format = "iso" )
37
40
df_dict = json .loads (df_json )
38
-
39
41
return JsonResponse (df_dict , safe = False )
0 commit comments