-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset.py
More file actions
29 lines (28 loc) · 1.22 KB
/
set.py
File metadata and controls
29 lines (28 loc) · 1.22 KB
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
# set.py - (Jarvis Mark-3)
# ------------------------
# This module is part of the Jarvis Mark-3 assistant system.
from geopy.geocoders import Nominatim
import geocoder
import requests
geolocator = Nominatim(user_agent="geoapiExercises")
def weather():
g = geocoder.ip('me')
if g.city is not None:
city=g.city
api_key = "66c28b29bcbee3e14525e8f4774b091e"
base_url = "https://api.openweathermap.org/data/2.5/weather?q="
city_name = city
complete_url = base_url + city_name + "&appid=" + api_key
response = requests.get(complete_url)
x = response.json()
if x["cod"] != "404":
y = x["main"]
current_temperature = y["temp"]
current_pressure = y["pressure"]
current_humidity = y["humidity"]
z = x["weather"]
weather_description = z[0]["description"]
forcast="temperature in " + city_name +" is " + str(round(current_temperature-273)) + " degrees celcius and humidity is " + str(current_humidity) + " percent and today's weather is " + str(weather_description)
return forcast
else:
return "Not able to get the weather information for your location"