Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
|
|
|
| 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
|