69 lines
2.1 KiB
HTML
69 lines
2.1 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Aktuelle Wetterdaten</title>
|
|
<style>
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
background-color: #f4f4f4;
|
|
margin: 0;
|
|
padding: 20px;
|
|
text-align: center;
|
|
}
|
|
h1 {
|
|
color: #333;
|
|
}
|
|
.weather-container {
|
|
max-width: 800px;
|
|
margin: 0 auto;
|
|
}
|
|
.station {
|
|
padding: 10px;
|
|
border: 1px solid #ddd;
|
|
margin-bottom: 10px;
|
|
background-color: white;
|
|
text-align: left;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>Aktuelle Wetterdaten</h1>
|
|
<div id="weather-container" class="weather-container">
|
|
<p>Daten werden geladen...</p>
|
|
</div>
|
|
|
|
<script>
|
|
// Funktion zum Abrufen der Wetterdaten von der Flask-API
|
|
async function fetchWeatherData() {
|
|
const response = await fetch('/weather');
|
|
const data = await response.json();
|
|
displayWeatherData(data);
|
|
}
|
|
|
|
// Funktion zum Anzeigen der Wetterdaten
|
|
function displayWeatherData(data) {
|
|
const container = document.getElementById('weather-container');
|
|
container.innerHTML = ''; // Lösche den Lade-Text
|
|
|
|
data.forEach(station => {
|
|
const stationDiv = document.createElement('div');
|
|
stationDiv.className = 'station';
|
|
stationDiv.innerHTML = `
|
|
<h3>${station.station}</h3>
|
|
<p>Temperatur: ${station.temperature.toFixed(2)}°C</p>
|
|
<p>Luftdruck: ${station.pressure} hPa</p>
|
|
<p>Windgeschwindigkeit: ${station.wind_speed} m/s</p>
|
|
<p>Wolkenbedeckung: ${station.cloud_cover}%</p>
|
|
`;
|
|
container.appendChild(stationDiv);
|
|
});
|
|
}
|
|
|
|
// Rufe die Wetterdaten ab, wenn die Seite geladen ist
|
|
window.onload = fetchWeatherData;
|
|
</script>
|
|
</body>
|
|
</html>
|