<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Weather Query</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            background-color: #e9ecef;
        }
        .container {
            max-width: 600px;
            margin: 50px auto;
            padding: 20px;
            background-color: white;
            border-radius: 8px;
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        }
        h1 {
            color: #333;
            text-align: center;
        }
        input[type="text"] {
            width: calc(100% - 22px);
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 5px;
            margin-bottom: 10px;
        }
        button {
            padding: 10px;
            border: none;
            border-radius: 5px;
            background-color: #007bff;
            color: white;
            font-size: 1em;
            cursor: pointer;
            display: block;
            margin: 0 auto;
        }
        button:hover {
            background-color: #0056b3;
        }
        .weather-info {
            margin-top: 20px;
        }
        .weather-info h2 {
            margin: 0;
        }
        .weather-info p {
            margin: 5px 0;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>Weather Query</h1>
        <input type="text" id="cityInput" placeholder="Enter city name">
        <button onclick="getWeather()">Get Weather</button>
        <div id="weatherInfo" class="weather-info"></div>
    </div>
    <script>
        function getWeather() {
            const city = document.getElementById('cityInput').value;
            if (city) {
                fetch(`https://api.openweathermap.org/data/2.5/weather?q=${city}&appid=YOUR_API_KEY`)
                .then(response => response.json())
                .then(data => {
                    const weatherInfo = document.getElementById('weatherInfo');
                    const temp = (data.main.temp - 273.15).toFixed(2); // Convert Kelvin to Celsius
                    weatherInfo.innerHTML = `
                        <h2>${data.name}</h2>
                        <p>Temperature: ${temp} °C</p>
                        <p>Weather: ${data.weather[0].description}</p>
                    `;
                })
                .catch(error => {
                    console.error('Error:', error);
                });
            } else {
                alert('Please enter a city name.');
            }
        }
    </script>
</body>
</html>