exports.get =
function
(request, response) {
var
httpRequest = require(
'request'
);
uri =
'http://graphical.weather.gov/xml/sample_products/browser_interface/ndfdBrowserClientByDay.php'
;
uri +=
'?citiesLevel=12&format=24+hourly&numDays=7'
httpRequest(uri,
(err, res, body) {
if
(err || res.statusCode !== 200) {
response.send(400, {
'message'
:
'Failed to connect to weather.'
});
}
else
{
// this is where the body content is processed and enriched
response.send(statusCodes.OK, {
: body });
};
: updateWeather() });
updateWeather =
() {
return
'Unable to connect to weather.'
body;
weather = {
lastUpdateDate:
null
,
updatedCount: 0,
data: {},
weather.data =
weather.lastUpdateDate =
new
Date();
weather.updatedCount += 1;
weather.data = body;
'LastUpdated'
: weather.lastUpdateDate,
'weather'
: weather.data
01.
02.
03.
console.log(
'weatherwatch count='
, weather.updatedCount);
04.
05.
06.
07.
08.
09.
10.
11.
setTimeout(
() { updateWeather() }, 1000);
12.
setInterval(
() { updateWeather() }, 86400000);
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
nice @@@
Congrats on the gold medal! blogs.technet.com/.../technet-guru-awards-august-2013.aspx