42Cummer commited on
Commit
90f46ca
·
verified ·
1 Parent(s): 580fb33

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -6,6 +6,7 @@ import requests
6
  from bs4 import BeautifulSoup
7
  import tempfile
8
  import os
 
9
 
10
  app = Flask(__name__)
11
  CORS(app)
@@ -93,9 +94,9 @@ def get_vehicle_destinations(route, stopcall):
93
  dest_par = soup.find('p', id=pattern)
94
 
95
  if dest_par:
96
- print(f"DEBUG: Found destination paragraph with id: {dest_par['id']}")
97
  contents = dest_par.contents
98
- print(f"DEBUG: Contents: {contents}")
99
  if len(contents) > 1 and "going" in contents[1]:
100
  stuff = contents[1].strip().split(" ")
101
  if len(stuff) > 1: branch = stuff[1]
@@ -106,7 +107,7 @@ def get_vehicle_destinations(route, stopcall):
106
  vehicle_info['destination'] = branch + " " + destination_text
107
  else:
108
  vehicle_info['destination'] = destination_text
109
- print(f"DEBUG: Extracted destination text: {destination_text}")
110
  else:
111
  vehicle_info['destination'] = []
112
  new_pattern = re.compile(rf'^{route}_{stopcall}\d*_\d*$')
@@ -311,11 +312,11 @@ def destinations():
311
  if not route:
312
  return jsonify({'error': 'route is required'}), 400
313
  info = get_vehicle_destinations(stopCall, route)
314
- return json(info)
315
-
316
  @app.route('/test_destinations')
317
  def test_destinations():
318
- return jsonify(get_vehicle_destinations('34', '1673'))
319
 
320
 
321
  if __name__ == '__main__':
 
6
  from bs4 import BeautifulSoup
7
  import tempfile
8
  import os
9
+ import sys
10
 
11
  app = Flask(__name__)
12
  CORS(app)
 
94
  dest_par = soup.find('p', id=pattern)
95
 
96
  if dest_par:
97
+ print(f"DEBUG: Found destination paragraph with id: {dest_par['id']}", file=sys.stderr)
98
  contents = dest_par.contents
99
+ print(f"DEBUG: Contents: {contents}", file=sys.stderr)
100
  if len(contents) > 1 and "going" in contents[1]:
101
  stuff = contents[1].strip().split(" ")
102
  if len(stuff) > 1: branch = stuff[1]
 
107
  vehicle_info['destination'] = branch + " " + destination_text
108
  else:
109
  vehicle_info['destination'] = destination_text
110
+ print(f"DEBUG: Extracted destination text: {destination_text}", file=sys.stderr)
111
  else:
112
  vehicle_info['destination'] = []
113
  new_pattern = re.compile(rf'^{route}_{stopcall}\d*_\d*$')
 
312
  if not route:
313
  return jsonify({'error': 'route is required'}), 400
314
  info = get_vehicle_destinations(stopCall, route)
315
+ return info
316
+
317
  @app.route('/test_destinations')
318
  def test_destinations():
319
+ return jsonify(get_vehicle_destinations('167', '6653'))
320
 
321
 
322
  if __name__ == '__main__':