GLaDOS446

weather Code wallpaper engine

Jul 24th, 2024
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.77 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6.     <title>Weather Wallpaper</title>
  7.     <style>
  8.         body {
  9.             margin: 0;
  10.             overflow: hidden;
  11.             display: flex;
  12.             justify-content: center;
  13.             align-items: center;
  14.             height: 100vh;
  15.             background-color: #282c34;
  16.             color: white;
  17.             font-family: Arial, sans-serif;
  18.         }
  19.         .weather-container {
  20.             text-align: center;
  21.         }
  22.     </style>
  23. </head>
  24. <body>
  25.     <div class="weather-container">
  26.         <h1 id="location">Loading...</h1>
  27.         <h2 id="temperature"></h2>
  28.         <h3 id="description"></h3>
  29.     </div>
  30.  
  31.     <script>
  32.         const API_KEY = 'YOUR_API_KEY';
  33.         const CITY = 'YOUR_CITY';
  34.  
  35.         async function fetchWeather() {
  36.             try {
  37.                 const response = await fetch(`https://api.openweathermap.org/data/2.5/weather?q=${CITY}&appid=${API_KEY}&units=metric`);
  38.                 const data = await response.json();
  39.                 updateWeather(data);
  40.             } catch (error) {
  41.                 console.error('Error fetching weather data:', error);
  42.             }
  43.         }
  44.  
  45.         function updateWeather(data) {
  46.             const location = document.getElementById('location');
  47.             const temperature = document.getElementById('temperature');
  48.             const description = document.getElementById('description');
  49.  
  50.             location.textContent = data.name;
  51.             temperature.textContent = `${data.main.temp}°C`;
  52.             description.textContent = data.weather[0].description;
  53.         }
  54.  
  55.         fetchWeather();
  56.         setInterval(fetchWeather, 600000); // Update every 10 minutes
  57.     </script>
  58. </body>
  59. </html>
Advertisement
Add Comment
Please, Sign In to add comment