A simple weather dashboard that displays current weather information for a searched city using the OpenWeatherMap API with a Node.js backend for secure API key handling.
- Search for weather by city name
- Display current temperature in Celsius
- Show weather condition (clear, rain, clouds, etc.)
- Display humidity percentage
- Secure API key handling through backend proxy
- Clone or download this repository
- Get an API key from OpenWeatherMap (free tier is sufficient)
- Create a
.envfile in the root directory and add:OPENWEATHER_API_KEY=your_api_key_here - Install dependencies:
npm install - Start the server:
npm start - Open your browser and navigate to
http://localhost:3000
- Frontend:
- HTML
- CSS
- JavaScript
- Backend:
- Node.js
- Express
- dotenv (for environment variables)
- cors (for handling cross-origin requests)
weather-dashboard/
βββ .env # Environment variables (API key)
βββ .gitignore # Git ignore file
βββ package.json # Node.js dependencies
βββ server.js # Express server and API proxy
βββ public/ # Static files
βββ index.html # HTML structure
βββ style.css # CSS styles
βββ script.js # Frontend JavaScript
This application uses a backend proxy to secure the API key. The key is stored in a .env file which is not committed to the repository. API requests are made through the backend, keeping the API key secure.
To use this application, you must obtain your own API key from OpenWeatherMap. The free tier allows up to 1,000 API calls per day, which is sufficient for personal use.