-
Notifications
You must be signed in to change notification settings - Fork 0
/
weather-app.html
54 lines (49 loc) · 1.74 KB
/
weather-app.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Weather API</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/style.css">
<style>
.card {
margin: 100px auto 0 auto;
}
</style>
</head>
<body>
<div class="card" style="width: 18rem;">
<img src="weather.jpg" class="card-img-top">
<div class="card-body">
<h5 class="card-title">City: <span class="city"></span></h5>
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item">Temperature: <span class="temp"></span><span class="badge bg-success countrycode"></span></li>
<li class="list-group-item">Condition: <span class="condition text-capitalize"></span></li>
<li class="list-group-item">Humidity: <span class="humid text-capitalize"></span></li>
</ul>
</div>
<!-- JS Files Here -->
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.bundle.min.js"></script>
<script>
$(document).ready(function () {
$.ajax({
url: "https://api.openweathermap.org/data/2.5/weather?q=Delhi&appid=YOURAPIKEYHERE&units=metric",
type: "GET",
dataType: "JSON",
success: function (data) {
// console.log(data);
$(".city").html(data.name);
$(".countrycode").html(data.sys.country);
$(".temp").html(data.main.temp + " Celsius");
$(".condition").html(data.weather[0].description);
$(".humid").html(data.main.humidity + " %");
}
});
});
</script>
</body>
</html>