From 49a5dea65f40cf122a6743f1e43d5b596dbe5f55 Mon Sep 17 00:00:00 2001 From: nicklassundin Date: Wed, 18 Dec 2024 15:28:29 +0100 Subject: [PATCH] send total stations number --- python/server.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/server.py b/python/server.py index 5a3ea96c7..f5bcc5af7 100644 --- a/python/server.py +++ b/python/server.py @@ -321,8 +321,9 @@ def get_stations(flush=False): def get_all_stations(): flush = request.args.get('flush') == 'true' stations_generator = get_stations(flush) - + total_stations = sum(1 for _ in stations_generator) # Count the total number of stations def generate(): + yield jsonify({'total_stations': total_stations}).data.decode('utf-8') + '\n' # Convert to JSON string and add newline for streaming for station in stations_generator: yield jsonify(station).data.decode('utf-8') + '\n' # Convert to JSON string and add newline for streaming