import requests
from pprint import pprint

API_KEY = "6d42d506c67e924b94101e7ebf0839e3"

def sprawdz_koordynaty(city, API_KEY):
    response = requests.get(f'http://api.openweathermap.org/geo/1.0/direct?q={city}&appid={API_KEY}')
    print(response.status_code)
    pprint(response.json())
    lat = response.json()[0]['lat']
    lon = response.json()[0]['lon']
    city = response.json()[0]['name']
    country = response.json()[0]['country']
    return lat, lon, city, country

print('Witaj, jestem aplikacją do sprawdzania pogody na świecie...')
origin_city = input('Podaj nazwe miasta z którego podrozujesz')
destination_city = input('Podaj nazwe miasta do ktorego podruzujesz')
origin_lat, origin_lon, origin_city, origin_country = sprawdz_koordynaty(origin_city, API_KEY)
destination_lat, destination_lon, destination_city, destination_country = sprawdz_koordynaty
(destination_city, API_KEY)

print(f'Miasto z ktorego podruzujesz: {origin_city}')
print(f'Miasto do ktorego podruzujesz: {destination_city}')
print(f'Jego wspolrzedne geograficzne to: \n{destination_lat} szerokosci geograficznej,\n{destination_lon} długości geograficznej')

def get_weather_info(lat, lon):
    response = requests.get(f'https://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&limit=1&appid={API_KEY}&lang=PL&units=metric')
    print(response.status_code)
    pprint(response.json())
    weather = response.json['weather'][0]['description']
    temp = response.json['main']['temp']
    pressure = response.json['main']['pressure']
    humidity = response.json['main']['humidity']
    return weather, temp, pressure, humidity