Created a very simple weather application using Node.js and Express, with a simple frontend to display weather information for a given city.
- Endpoints:
GET /: Serves an HTML file (index.html) as the main page. POST /: Handles form submissions to fetch weather data from the OpenWeatherMap API based on the city name input.
- API Integration:
Upon receiving a city name from a form, the server makes a request to the OpenWeatherMap API. The API response is parsed to extract temperature and weather description. The server sends this data back to the client as HTML.
- HTML (index.html):
Basic structure with an input field for the city name and a button to trigger the weather fetch.A container to display the weather information.
-
CSS: An external stylesheet (app.css) linked to the HTML (path corrected).
-
JavaScript: A function (getWeather()) to fetch weather data from the OpenWeatherMap API using fetch when the button is clicked. The fetched data is displayed dynamically on the page.