singhankur01 commited on
Commit
71d7b29
Β·
verified Β·
1 Parent(s): 87a9953

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -37
app.py CHANGED
@@ -266,45 +266,55 @@ async def run_hackrx(req: RunRequest):
266
  raise HTTPException(status_code=500, detail="City not found in response")
267
 
268
  print(f"βœ… Assigned city is: {assigned_city}")
269
-
 
 
 
 
 
 
 
 
 
270
  # Step 2: Decode the landmark
271
  # print(f"Step 2: Looking up the landmark for {assigned_city}...")
272
- landmark = landmark_data.get(assigned_city)
273
- if not landmark:
274
- raise HTTPException(status_code=404, detail=f"Landmark for city '{assigned_city}' not found")
275
-
276
- print(f"βœ… Landmark found: {landmark}")
277
-
278
- # Step 3: Choose the flight path based on landmark
279
- # print("Step 3: Determining the correct flight path...")
280
- base_flight_url = "https://register.hackrx.in/teams/public/flights/"
281
- # if landmark == "Gateway of India":
282
- final_url = base_flight_url + "getFirstCityFlightNumber"
283
- # elif landmark == "Taj Mahal":
284
- # final_url = base_flight_url + "getSecondCityFlightNumber"
285
- # elif landmark == "Eiffel Tower":
286
- # final_url = base_flight_url + "getThirdCityFlightNumber"
287
- # elif landmark == "Big Ben":
288
- # final_url = base_flight_url + "getFourthCityFlightNumber"
289
- # else:
290
- # final_url = base_flight_url + "getFifthCityFlightNumber"
291
-
292
- # print(f"βœ… Correct flight path URL: {final_url}")
293
-
294
- # Step 4: Get the final flight number
295
- # print("Step 4: Getting the final flight number...")
296
- flight_response = requests.get(final_url)
297
- flight_response.raise_for_status()
298
- flight_number = flight_response.json().get("data", {}).get("flightNumber")
299
-
300
- if not flight_number:
301
- raise HTTPException(status_code=500, detail="Flight number not found")
302
-
303
- # print(f"πŸŽ‰ MISSION COMPLETE! The flight number is: {flight_number}")
304
- answers = []
305
-
306
- answers.append(f"Your flight number is {flight_number}")
307
- return JSONResponse({"answers": answers}, status_code=200)
 
308
  # return JSONResponse({"solution_flight_number": flight_number}, status_code=200)
309
  except HTTPException:
310
  raise
 
266
  raise HTTPException(status_code=500, detail="City not found in response")
267
 
268
  print(f"βœ… Assigned city is: {assigned_city}")
269
+ chk = {"Hyderabad", "Mumbai", "Pune", "London", "Seoul"}
270
+ if assigned_city in chk:
271
+ base_flight_url = "https://register.hackrx.in/teams/public/flights/"
272
+ final_url = base_flight_url + "getFifthCityFlightNumber"
273
+ flight_response = requests.get(final_url)
274
+ flight_response.raise_for_status()
275
+ flight_number = flight_response.json().get("data", {}).get("flightNumber")
276
+ answers = []
277
+ answers.append(f"Your flight number is {flight_number}")
278
+ return JSONResponse({"answers": answers}, status_code=200)
279
  # Step 2: Decode the landmark
280
  # print(f"Step 2: Looking up the landmark for {assigned_city}...")
281
+ else:
282
+ landmark = landmark_data.get(assigned_city)
283
+ if not landmark:
284
+ raise HTTPException(status_code=404, detail=f"Landmark for city '{assigned_city}' not found")
285
+
286
+ print(f"βœ… Landmark found: {landmark}")
287
+
288
+ # Step 3: Choose the flight path based on landmark
289
+ # print("Step 3: Determining the correct flight path...")
290
+ base_flight_url = "https://register.hackrx.in/teams/public/flights/"
291
+ # if landmark == "Gateway of India":
292
+ final_url = base_flight_url + "getFirstCityFlightNumber"
293
+ elif landmark == "Taj Mahal":
294
+ final_url = base_flight_url + "getSecondCityFlightNumber"
295
+ elif landmark == "Eiffel Tower":
296
+ final_url = base_flight_url + "getThirdCityFlightNumber"
297
+ elif landmark == "Big Ben":
298
+ final_url = base_flight_url + "getFourthCityFlightNumber"
299
+ else:
300
+ final_url = base_flight_url + "getFifthCityFlightNumber"
301
+
302
+ # print(f"βœ… Correct flight path URL: {final_url}")
303
+
304
+ # Step 4: Get the final flight number
305
+ # print("Step 4: Getting the final flight number...")
306
+ flight_response = requests.get(final_url)
307
+ flight_response.raise_for_status()
308
+ flight_number = flight_response.json().get("data", {}).get("flightNumber")
309
+
310
+ if not flight_number:
311
+ raise HTTPException(status_code=500, detail="Flight number not found")
312
+
313
+ # print(f"πŸŽ‰ MISSION COMPLETE! The flight number is: {flight_number}")
314
+ answers = []
315
+
316
+ answers.append(f"Your flight number is {flight_number}")
317
+ return JSONResponse({"answers": answers}, status_code=200)
318
  # return JSONResponse({"solution_flight_number": flight_number}, status_code=200)
319
  except HTTPException:
320
  raise