-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
39 lines (30 loc) · 929 Bytes
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<!DOCTYPE html>
<html>
<head>
<title>Weather API</title>
</head>
<body>
<div id="current_weather"></div>
<script src="./bower_components/jquery/dist/jquery.min.js"></script>
<script src="./bower_components/axios/dist/axios.min.js"></script>
<!--have to publish api key from http://openweathermap.org -->
<script src="./apikey.js"></script>
<script>
var region = "Seoul,kr";
var current_weather = $('#current_weather');
axios.get('http://api.openweathermap.org/data/2.5/weather?q='+region+'&appid=' + APIKEY)
.then(function (response) {
// console.log(response);
//console.log(response.data.weather[0].icon);
var weather_img = $('<img />', {
src: 'http://openweathermap.org/img/w/'+response.data.weather[0].icon+'.png',
alt: ''
});
current_weather.append(weather_img);
})
.catch(function (error) {
console.log(error);
});
</script>
</body>
</html>