Commit 3e8cd911 authored by EnesKarakas's avatar EnesKarakas
Browse files

Frontend

parent 0a033491
......@@ -4,8 +4,40 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="styles/styles.css" />
<script src="scripts/script.js"></script>
<title>Wetterdaten sammeln</title>
<title>Wetter App</title>
</head>
<body></body>
<body>
<div class="container">
<div class="box">
<h1>Wetterdaten abrufen</h1>
<div class="filter">
<label for="city">Stadt:</label>
<input type="text" id="city" placeholder="Stadt" /><br />
<label for="start">Startdatum:</label>
<input type="date" id="start" value="2024-04-24" /><br />
<label for="end">Enddatum:</label>
<input type="date" id="end" value="2024-05-08" /><br />
<label for="storage">Speicherort:</label>
<select id="storage">
<option value="local">Lokal</option>
<option value="database">Datenbank</option></select
><br />
<label for="format">Datenformat:</label>
<select id="format">
<option value="json">JSON</option>
<option value="csv">CSV</option>
<option value="xml">XML</option></select
><br />
<button onclick="getData()">Daten abrufen</button>
</div>
</div>
<div class="box">
<h2>Wetterdaten</h2>
<pre id="weatherData"></pre>
</div>
</div>
<script type="text/javascript" src="scripts/script.js"></script>
</body>
</html>
function getData() {
const city = document.getElementById("city").value;
const start = document.getElementById("start").value;
const end = document.getElementById("end").value;
const storageOption = document.getElementById("storage").value;
const formatOption = document.getElementById("format").value;
const apiKey = "1244099aeaee4b179e6111803241304";
const apiUrl = `https://api.weatherapi.com/v1/current.json?key=${apiKey}&q=${city}&aqi=no`;
fetch(apiUrl)
.then((response) => {
if (!response.ok) {
throw new Error("Network response was not ok");
}
return response.json();
})
.then((data) => {
// Wetterdaten anzeigen
document.getElementById("weatherData").innerText = JSON.stringify(
data,
null,
2
);
})
.catch((error) => {
console.error("There was a problem with the fetch operation:", error);
});
}
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
.container {
max-width: 800px;
margin: 20px auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.box {
margin-bottom: 20px;
}
.filter label {
display: block;
margin-bottom: 5px;
}
.filter input[type="text"],
.filter select {
width: 100%;
padding: 8px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 5px;
}
.filter button {
padding: 10px 20px;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
}
.filter button:hover {
background-color: #0056b3;
}
#weatherData {
white-space: pre-wrap; /* Umbruch von langen Zeilen */
}
......@@ -8,6 +8,7 @@ public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment