Correctly using secret key
Browse files- tools/cheapest_flight.py +5 -3
tools/cheapest_flight.py
CHANGED
@@ -2,7 +2,7 @@ import http.client
|
|
2 |
import pandas as pd
|
3 |
import numpy as np
|
4 |
import json
|
5 |
-
|
6 |
|
7 |
|
8 |
|
@@ -10,8 +10,10 @@ def get_flight(departureId, arrivalId, departureDate):
|
|
10 |
|
11 |
conn = http.client.HTTPSConnection("booking-com15.p.rapidapi.com")
|
12 |
|
|
|
|
|
13 |
headers = {
|
14 |
-
'x-rapidapi-key':
|
15 |
'x-rapidapi-host': "booking-com15.p.rapidapi.com"
|
16 |
}
|
17 |
|
@@ -55,7 +57,7 @@ def get_flight(departureId, arrivalId, departureDate):
|
|
55 |
cheapest_flight = offer
|
56 |
except (ValueError, TypeError):
|
57 |
continue
|
58 |
-
|
59 |
# Extract relevant info from cheapest flight
|
60 |
if cheapest_flight:
|
61 |
try:
|
|
|
2 |
import pandas as pd
|
3 |
import numpy as np
|
4 |
import json
|
5 |
+
import os
|
6 |
|
7 |
|
8 |
|
|
|
10 |
|
11 |
conn = http.client.HTTPSConnection("booking-com15.p.rapidapi.com")
|
12 |
|
13 |
+
rapid_key = os.getenv("RAPIDAPI_KEY")
|
14 |
+
|
15 |
headers = {
|
16 |
+
'x-rapidapi-key': rapid_key, #Replace with your own RapidAPI key
|
17 |
'x-rapidapi-host': "booking-com15.p.rapidapi.com"
|
18 |
}
|
19 |
|
|
|
57 |
cheapest_flight = offer
|
58 |
except (ValueError, TypeError):
|
59 |
continue
|
60 |
+
|
61 |
# Extract relevant info from cheapest flight
|
62 |
if cheapest_flight:
|
63 |
try:
|