Skip to content

Commit ac6f445

Browse files
Add RunIt entry point for deploying as a live API
Exposes search_flights() as a plain function that RunIt's pipeline can auto-wrap into a FastAPI endpoint. Uses the real SearchEngine with Google Flights (no API keys needed). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent fd9c0fe commit ac6f445

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

main.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
"""RunIt entry point: exposes OpenSky's SearchEngine as a deployable function."""
2+
3+
from opensky.search import SearchEngine
4+
5+
6+
def search_flights(
7+
origin: str = "BER",
8+
destination: str = "LHR",
9+
date: str = "2026-04-01",
10+
currency: str = "EUR",
11+
max_price: float = 500.0,
12+
) -> dict:
13+
"""Search flights between airports. Uses real airline data, no API keys needed."""
14+
engine = SearchEngine(currency=currency)
15+
try:
16+
results = engine.search_scored(
17+
origin.upper(),
18+
destination.upper(),
19+
date,
20+
max_price=max_price,
21+
)
22+
flights = []
23+
for sf in results:
24+
f = sf.flight
25+
flight = {
26+
"origin": sf.origin,
27+
"destination": sf.destination,
28+
"date": sf.date,
29+
"route": sf.route,
30+
"price": f.price,
31+
"currency": f.currency,
32+
"stops": f.stops,
33+
"duration_minutes": f.duration_minutes,
34+
"provider": f.provider,
35+
"risk_level": sf.risk.risk_level.value,
36+
}
37+
if f.booking_url:
38+
flight["booking_url"] = f.booking_url
39+
flights.append(flight)
40+
41+
return {
42+
"route": f"{origin.upper()} -> {destination.upper()}",
43+
"date": date,
44+
"currency": currency,
45+
"total_results": len(flights),
46+
"flights": sorted(flights, key=lambda x: x["price"]),
47+
}
48+
finally:
49+
engine.close()

0 commit comments

Comments
 (0)