diff --git a/weather.cgi b/weather.cgi index be7819c..8bff1b3 100755 --- a/weather.cgi +++ b/weather.cgi @@ -1,12 +1,28 @@ #!/usr/bin/python # -*- coding: utf-8 -*- +# These are the items that can be customized for a different location. +# The zipcode is just the 5-digit code; no need for extensions. +# The station can be found by going to +# http://www.weather.gov/xml/current_obs/seek.php?state=il&Find=Find +# and choosing the closest NOAA station for your state. +# The radar image can be found at http://weather.com by searching +# on your location and then following the "Classic Map" link. Use +# the URL of that image here. +zipcode = '60502' +station = 'KARR' +radar = 'http://i.imwx.com/web/radar/us_ord_ultraradar_plus_usen.jpg' + + +# The code below shouldn't be modified unless you want to change the layout +# or the type of data presented. + import pywapi import datetime import re -import cgitb -cgitb.enable() +# import cgitb +# cgitb.enable() # The date and time as a string. Note: My host's server is on Eastern Time # and I'm on Central Time, so I subtract an hour. @@ -17,8 +33,8 @@ now = re.sub(r' 0(\d )', r' \1', now) # day has a space before and after now = re.sub(r'0(\d:)', r'\1', now) # hour has a colon after # Get the current conditions for the given station. -noaa = pywapi.get_weather_from_noaa('KARR') -yahoo = pywapi.get_weather_from_yahoo('60502', '') +noaa = pywapi.get_weather_from_noaa(station) +yahoo = pywapi.get_weather_from_yahoo(zipcode, '') # Interpretation of the Yahoo pressure dictionary. ypressure = {'0': 'steady', '1': 'rising', '2': 'falling'} @@ -67,7 +83,7 @@ content += 'Pressure: %s and %s
\n' % (float(yahoo['atmosphere']['pressure' content += 'Sunlight: %s to %s

\n' % (yahoo['astronomy']['sunrise'], yahoo['astronomy']['sunset']) -content += '

\n' +content += '

\n' % radar content += '''

Today

High: %s°