Skip to content

Commit

Permalink
first push
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Meyer committed Jan 23, 2020
1 parent 7d42417 commit 16b3da3
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_pycache_
Binary file added __pycache__/config.cpython-37.pyc
Binary file not shown.
4 changes: 4 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
api_key = 'cbe14ed2a206c188303087c3bfd80202'
api_id = 'fd2cdee9'
snow_url = 'https://api.weatherunlocked.com/api/snowreport/13003?hourly_interval=6&app_id=fd2cdee9&app_key=cbe14ed2a206c188303087c3bfd80202'
forecast_url = 'https://api.weatherunlocked.com/api/resortforecast/13003?app_id=fd2cdee9&app_key=cbe14ed2a206c188303087c3bfd80202'
36 changes: 36 additions & 0 deletions snow_notify.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import requests
import json
import urllib.request as request
import config

# with request.urlopen('https://api.weatherunlocked.com/api/snowreport/13003?app_id=fd2cdee9&app_key=cbe14ed2a206c188303087c3bfd80202') as response:
# if response.getcode() == 200:
# source = response.read()
# data = json.loads(source)
# else:
# print('An error occurred while attempting to retrieve the API data.')

# type(data)
# data.keys()
# type(data['lowersnow_in'])
# print(type(data['lowersnow_in']).float)
api_id = config.api_id
api_key = config.api_key



snow_request = requests.get(config.snow_url)
snow_report = snow_request.json()
print(snow_report)
print("Lower snow report:",snow_report['lowersnow_in'],"inches.")
if snow_report['newsnow_in'] >= 3:
print('You got Snow!')
print('The last snowfall size was',snow_report['lastsnow_in'],'inches.')
print('The snow type is',snow_report['conditions'],'.')
else:
print('Hopefully soon!')
print('The last snowfall size was',snow_report['lastsnow_in'],'inches on',snow_report['lastsnow'])

forecast_request = requests.get(config.forecast_url)
forecast_report = forecast_request.json()
print(forecast_report)

0 comments on commit 16b3da3

Please sign in to comment.