Skip to content

Commit

Permalink
send total stations number
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklassundin committed Dec 18, 2024
1 parent 1ed710e commit 49a5dea
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion python/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 49a5dea

Please sign in to comment.