diff --git a/public/OpenWeatherForecastApp/README.md b/public/OpenWeatherForecastApp/README.md new file mode 100644 index 000000000..e69de29bb diff --git a/public/OpenWeatherForecastApp/index.html b/public/OpenWeatherForecastApp/index.html new file mode 100644 index 000000000..03a7281c6 --- /dev/null +++ b/public/OpenWeatherForecastApp/index.html @@ -0,0 +1,24 @@ + + +
+ + +Please enter a city name.
"; + return; + } + + weatherData.innerHTML = "Loading...
"; + + const url = `https://api.openweathermap.org/data/2.5/weather?q=${city}&appid=${API_KEY}&units=metric`; + + try { + const response = await fetch(url); + + if (!response.ok) { + throw new Error("City not found"); + } + + const data = await response.json(); + + weatherData.innerHTML = ` +${data.weather[0].main}
+${data.weather[0].description}
+ +🌡 Temperature: ${data.main.temp} °C
+🌡 Feels Like: ${data.main.feels_like} °C
+💧 Humidity: ${data.main.humidity}%
+🌬 Wind Speed: ${data.wind.speed} m/s
+`; + } catch (error) { + console.log(error); + weatherData.innerHTML = + `${error.message}
`; + } + } + document + .getElementById("cityInput") + .addEventListener("keypress", function(event) { + if (event.key === "Enter") { + getWeather(); + } + }); + \ No newline at end of file diff --git a/public/OpenWeatherForecastApp/style.css b/public/OpenWeatherForecastApp/style.css new file mode 100644 index 000000000..e977762a1 --- /dev/null +++ b/public/OpenWeatherForecastApp/style.css @@ -0,0 +1,69 @@ +* { + margin: 0; + padding: 0; + box-sizing: border-box; + font-family: Arial, sans-serif; +} + +body { + min-height: 100vh; + background: linear-gradient(135deg, #4facfe, #00f2fe); + display: flex; + justify-content: center; + align-items: center; +} + +.container { + width: 90%; + max-width: 450px; + background: white; + padding: 25px; + border-radius: 15px; + text-align: center; + box-shadow: 0 5px 20px rgba(0,0,0,0.2); +} + +h1 { + margin-bottom: 20px; + color: #333; +} + +.search-box { + display: flex; + gap: 10px; + margin-bottom: 20px; +} + +.search-box input { + flex: 1; + padding: 10px; + border: 2px solid #ddd; + border-radius: 8px; + outline: none; +} + +.search-box button { + padding: 10px 15px; + border: none; + background: #0077ff; + color: white; + border-radius: 8px; + cursor: pointer; +} + +.search-box button:hover { + background: #005edb; +} + +#weatherData { + margin-top: 20px; +} + +.weather-icon { + width: 100px; + height: 100px; +} +.error { + color: red; + font-weight: bold; +} \ No newline at end of file