42Cummer commited on
Commit
1d7a49e
·
verified ·
1 Parent(s): 0083f50

remove debug and typo

Browse files
Files changed (1) hide show
  1. app.py +2 -14
app.py CHANGED
@@ -268,24 +268,17 @@ def getVehicleInfo(vehicle_id):
268
  # Extract destination - only the text before <br>
269
  destination = None
270
 
271
- # Debug: print the raw HTML
272
- print(f"DEBUG - Raw HTML: {html_content}")
273
-
274
  # Split by <br> and get only the first part
275
  before_br = html_content.split('<br/>')[0].split('<br>')[0]
276
- print(f"DEBUG - Before BR: {before_br}")
277
 
278
  # Look for the quoted destination text that contains direction words
279
  dest_match = re.search(r'"([^"]*(?:South|North|East|West)[^"]*)"', before_br)
280
  if dest_match:
281
  raw_dest = dest_match.group(1).strip()
282
- print(f"DEBUG - Raw destination: {raw_dest}")
283
  # Clean up - remove anything after "at " or "on " which indicates location details
284
  clean_dest = re.sub(r'at\s+.*$', '', raw_dest)
285
  destination = clean_dest.strip()
286
- print(f"DEBUG - Clean destination: {destination}")
287
  else:
288
- print("DEBUG - No direction-containing quoted text found, using fallback")
289
  # Fallback: extract text content and look for direction patterns
290
  temp_soup = BeautifulSoup(before_br, 'html.parser')
291
  text_content = temp_soup.get_text()
@@ -295,10 +288,7 @@ def getVehicleInfo(vehicle_id):
295
  clean_dest = re.sub(r'at\s+.*$', '', raw_dest)
296
  destination = clean_dest.strip()
297
 
298
- return jsonify({
299
- "direction": direction,
300
- "destination": destination
301
- })
302
 
303
 
304
  @app.route('/seek', methods=['POST'])
@@ -484,9 +474,7 @@ def seek():
484
  vehicle_data['vehicle_number'] = None
485
 
486
  if vehicle_data['vehicle_number'] is None: continue
487
- vehicle_info = getVehicleInfo(vehicle_data['vehicle_number'])
488
- vehicle_data['direction'] = vehicle_info['direction']
489
- vehicle_data['destination'] = vehicle_info['destination']
490
  vehicles.append(vehicle_data)
491
 
492
  return jsonify({
 
268
  # Extract destination - only the text before <br>
269
  destination = None
270
 
 
 
 
271
  # Split by <br> and get only the first part
272
  before_br = html_content.split('<br/>')[0].split('<br>')[0]
 
273
 
274
  # Look for the quoted destination text that contains direction words
275
  dest_match = re.search(r'"([^"]*(?:South|North|East|West)[^"]*)"', before_br)
276
  if dest_match:
277
  raw_dest = dest_match.group(1).strip()
 
278
  # Clean up - remove anything after "at " or "on " which indicates location details
279
  clean_dest = re.sub(r'at\s+.*$', '', raw_dest)
280
  destination = clean_dest.strip()
 
281
  else:
 
282
  # Fallback: extract text content and look for direction patterns
283
  temp_soup = BeautifulSoup(before_br, 'html.parser')
284
  text_content = temp_soup.get_text()
 
288
  clean_dest = re.sub(r'at\s+.*$', '', raw_dest)
289
  destination = clean_dest.strip()
290
 
291
+ return direction, destination
 
 
 
292
 
293
 
294
  @app.route('/seek', methods=['POST'])
 
474
  vehicle_data['vehicle_number'] = None
475
 
476
  if vehicle_data['vehicle_number'] is None: continue
477
+ vehicle_data['direction'], vehicle_data['destination'] = getVehicleInfo(vehicle_data['vehicle_number'])
 
 
478
  vehicles.append(vehicle_data)
479
 
480
  return jsonify({