Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
ChatBot_A6/Weather.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
26 lines (17 sloc)
1014 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This module was written primarily by Vinayak Sareen and edited slightly by Humza Shahid for GUI integration. | |
#To see Vinayak's original work, compare this file with the other Weather.py in this repository. This Weather.py contains Humza's changes. | |
import requests | |
'''Function to get data from openweather.org''' | |
def get_User_city(User_city,User_Country): | |
Weather_Api_Link = 'http://api.openweathermap.org/data/2.5/weather?APPID=d98cf0f33972375849da99fef900c4f8&units=metric&q=' | |
Url = Weather_Api_Link + User_city + "&" + User_Country | |
Jasondata = requests.get(Url).json() | |
return Jasondata | |
#Data Sorting and Displaying | |
def Data_Sorting(Users_city,Users_country): | |
json_data = get_User_city(Users_city,Users_country) # Fuction calling | |
Minimum_temp = json_data['main']['temp_min'] | |
Maximum_temp = json_data['main']['temp_max'] | |
Humidity = json_data['main']['humidity'] | |
Description = json_data['weather'][0]['description'] | |
return Minimum_temp, Maximum_temp, Description |