-
Notifications
You must be signed in to change notification settings - Fork 4
/
Weather.py
58 lines (29 loc) · 1.25 KB
/
Weather.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import requests
import Config
import Speak
BASE_URL = "https://api.openweathermap.org/data/2.5/weather?"
CITY = Config.BASE_CITY
API_KEY = Config.AUTH_KEY
class get_Weather:
def __init__(self):
Speak.Speak("Please wait for get weather details")
URL = BASE_URL + "q=" + CITY + "&appid=" + API_KEY
response = requests.get(URL)
if response.status_code == 200:
data = response.json()
main = data['main']
temperature = main['temp']
temp_feel_like = main['feels_like']
humidity = main['humidity']
pressure = main['pressure']
weather_report = data['weather']
wind_report = data['wind']
Speak.Speak('Here Today Weather Report In '+CITY)
Speak.Speak(f" Today Weather Like {weather_report[0]['description']}")
Speak.Speak(f"Temperature: {temperature} in Kelvin")
Speak.Speak(f"Feel Like: {temp_feel_like} in Kelvin")
Speak.Speak(f"Humidity: {humidity} Parentage")
Speak.Speak(f"Pressure: {pressure} in pascal")
Speak.Speak(f"Wind Speed: {wind_report['speed']} kilometre per hour")
else:
Speak.Speak("Error in the HTTP request")