making modules preparing for flask integration

This commit is contained in:
Arnold Dechamps 2024-03-19 01:38:47 +01:00
parent d1657f17d6
commit 2b695214ca
No known key found for this signature in database
GPG key ID: AE66543374E41C89

View file

@ -4,17 +4,30 @@ Little script written by Arnold Dechamps
import config
import requests
apiUrl = "https://aeroapi.flightaware.com/aeroapi/"
airport = config.AIRPORT
payload = {'max_pages': 2}
auth_header = {'x-apikey': config.FLIGHTAWAREKEY}
def main():
"""
Main function to pull data from flightaware API. Mostly flightaware code with overhead. Will modify if needed
:return: raw data
"""
departures = []
apiUrl = "https://aeroapi.flightaware.com/aeroapi/"
airport = config.AIRPORT
payload = {'max_pages': 2}
auth_header = {'x-apikey': config.FLIGHTAWAREKEY}
response = requests.get(apiUrl + f"airports/{airport}/flights/scheduled_departures", params=payload,
headers=auth_header)
print("Flight Operator Time Destination acft-type")
if response.status_code == 200:
departures = response.json()["scheduled_departures"]
response = requests.get(apiUrl + f"airports/{airport}/flights/scheduled_departures", params=payload,
headers=auth_header)
print("Flight Operator Time Destination acft-type")
if response.status_code == 200:
departures = response.json()["scheduled_departures"]
else:
print("Error executing request")
return departures
if __name__ == '__main__':
departures = main()
name = "unknown"
operator = "unknown"
scheduled_off = "unknown"
@ -34,5 +47,3 @@ if response.status_code == 200:
acfttype = flight["aircraft_type"]
print(name + " " + operator + " " + scheduled_off + " " + destination + " " + acfttype)
else:
print("Error executing request")