mirror of
https://gitlab.silvrtree.co.uk/martind2000/old-silvrgit.git
synced 2025-01-10 21:55:08 +00:00
updated weather
This commit is contained in:
parent
3723b544ce
commit
e2463d19bc
@ -11,8 +11,10 @@ html(lang="en")
|
||||
h2 Weather
|
||||
p Currently:
|
||||
= ' ' + data.weather.currently
|
||||
p Later:
|
||||
p Today:
|
||||
= ' ' + data.weather.today
|
||||
p Later:
|
||||
= ' ' + data.weather.later
|
||||
|
||||
if data.weather.alerts.length > 0
|
||||
h3 ALERT
|
||||
|
@ -251,7 +251,8 @@ module.exports = {
|
||||
if (err) throw err;
|
||||
|
||||
j.currently = data.currently.summary;
|
||||
j.today = data.daily.summary;
|
||||
j.today = data.daily[0].summary;
|
||||
j.later = data.daily.summary;
|
||||
j.alerts = data.alerts || {};
|
||||
|
||||
todayCache.data.weather = j;
|
||||
|
44
lib/weather.js
Normal file
44
lib/weather.js
Normal file
@ -0,0 +1,44 @@
|
||||
/**
|
||||
* Created by marti on 14/02/2016.
|
||||
*/
|
||||
var http = require('http'), request = require('request'), cheerio = require('cheerio'), Forecast = require('forecast.io'), util = require('util'), UltraSES = require('ultrases'), cron = require('node-cron');
|
||||
var jade = require('jade'), _ = require('lodash'), dateFormat = require('dateformat');
|
||||
var jsonfile = require('jsonfile'), fs = require('fs');
|
||||
var log4js = require('log4js');
|
||||
var logger = log4js.getLogger();
|
||||
|
||||
var forecastOptions = {
|
||||
APIKey: '0657dc0d81c037cbc89ca88e383b6bbf',
|
||||
units: 'uk2'
|
||||
};
|
||||
|
||||
var file = __dirname + '/' + 'data.json';
|
||||
function saveData(d) {
|
||||
jsonfile.writeFileSync(file, d);
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
|
||||
doGetWeatherOutlook: function () {
|
||||
console.log('Retrieving weather..');
|
||||
var j = {};
|
||||
var forecast = new Forecast(forecastOptions);
|
||||
forecast.get(55.8582846, -4.2593033, {units: 'uk2'}, function (err, res, data) {
|
||||
if (err) throw err;
|
||||
console.log(util.inspect(data));
|
||||
saveData(data);
|
||||
j.currently = data.currently.summary;
|
||||
j.today = data.daily[0].summary;
|
||||
j.later = data.daily.summary;
|
||||
j.alerts = data.alerts || {};
|
||||
|
||||
// todayCache.data.weather = j;
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
module.exports.doGetWeatherOutlook();
|
Loading…
Reference in New Issue
Block a user