A weather site in six (declarative) lines

For several years I maintained a hodge-podge of little web-based utilities at toolbot.com. Recently I decided to wipe the slate clean, bringing things back selectively. One of the few that I missed personally was my weather site. It returned National Weather Service forecasts in response to compact URLs of the form weather.toolbot.com/05667, for any five-digit US zipcode.

Originally, the site worked by scraping plaintext forecast files on the NWS servers. Eventually those went away; I looked at and gave up on the arcane (to me) SOAP interface that superseded them. All I wanted was a damn weather forecast, without ads, via an easy-to-type-no-matter-where-I-am URL.

I brought it back without writing a line of procedural code. You can click the link above to try it. Here’s the entirety of the Apache configuration for this host (I use wildcard subdomains, so there’s no DNS configuration step).

<VirtualHost *>
ServerName weather.toolbot.com
ServerAlias wx.toolbot.com
RewriteEngine On
RewriteRule ^/(\d{5})$ http://forecast.weather.gov/zipcity.php?inputstring=$1
</VirtualHost>

A cheap hack, but a useful cheap hack. Steal my code and create your own private weather redirect today! (Or just use mine.)



Share: