Files
wetterapp/templates/index.html
SimolZimol 70e0c36724 modified: app.py
modified:   templates/index.html
2024-09-10 14:56:00 +02:00

83 lines
2.4 KiB
HTML

<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Wetterdaten nach Stationen</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
margin: 0;
padding: 20px;
background-color: #f4f4f4;
}
table {
width: 100%;
border-collapse: collapse;
margin: 20px 0;
}
table, th, td {
border: 1px solid black;
}
th, td {
padding: 10px;
text-align: center;
}
th {
background-color: #007BFF;
color: white;
}
</style>
</head>
<body>
<h1>Wetterdaten nach Stationen</h1>
<table>
<thead>
<tr>
<th>Station Nummer</th>
<th>Station Name</th>
<th>Temperatur (K)</th>
<th>Taupunkt (K)</th>
<th>Relative Luftfeuchtigkeit (%)</th>
<th>Windgeschwindigkeit (m/s)</th>
</tr>
</thead>
<tbody id="weather-table-body">
<!-- Daten werden hier geladen -->
</tbody>
</table>
<script>
async function fetchWeatherData() {
const response = await fetch('/weather_data');
const data = await response.json();
const tableBody = document.getElementById('weather-table-body');
tableBody.innerHTML = ''; // Tabelle leeren
data.forEach(station => {
const row = document.createElement('tr');
row.innerHTML = `
<td>${station.stationNumber || 'N/A'}</td>
<td>${station.stationName || 'N/A'}</td>
<td>${station.temperature ? station.temperature.toFixed(2) : 'N/A'}</td>
<td>${station.dewpoint ? station.dewpoint.toFixed(2) : 'N/A'}</td>
<td>${station.humidity ? station.humidity.toFixed(2) : 'N/A'}</td>
<td>${station.windSpeed ? station.windSpeed.toFixed(2) : 'N/A'}</td>
`;
tableBody.appendChild(row);
});
}
// Wetterdaten laden, sobald die Seite geladen ist
window.onload = fetchWeatherData;
</script>
</body>
</html>