0% found this document useful (0 votes)
7 views

Week 1 - Assignment

Hello2

Uploaded by

hello125643
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Week 1 - Assignment

Hello2

Uploaded by

hello125643
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Week 1 Assignment

Weather App using Node.js with a Templating Engine

Objective
Create a web-based weather application using Node.js, Express, and a templating
engine (like EJS or Pug). This app will fetch and display the weather information of a
city entered by the user. The goal of this project is to learn how to set up a Node.js
server, integrate a templating engine, and make HTTP requests to external APIs.

Requirements

1. User Interface:
- Create a form where users can input a city name.
- Upon form submission, the app should display the weather information of the city.

2. Templating Engine:
- Use a templating engine like EJS or Pug to render dynamic HTML pages.
- Display the weather information dynamically based on the city entered.

3. API Integration:
- Use the OpenWeatherMap API (https://openweathermap.org/api) or another weather
API to fetch weather data.
- The API key should be stored in environment variables (`.env` file).

4. Display Weather Information:


- Show weather details such as:
- City name
- Current temperature (in Celsius or Fahrenheit)
- Weather description (e.g., sunny, cloudy, rainy)
- Humidity level
- Wind speed
- An icon or text-based symbol representing the weather (e.g., sun, cloud, etc.).
5. Error Handling:
- Display a user-friendly error message if:
- The city name is invalid or not found.
- The weather API request fails (e.g., network issues, missing API key).

Technical Requirements:

1. Node.js and Express Setup:


- Create a Node.js server using Express to handle HTTP requests.
- Serve static assets (CSS, images, etc.) using Express.

2. Templating Engine:
- Use EJS, Pug, or Handlebars to create dynamic views.
- Render the weather data on the web page using the templating engine.

3. Environment Variables:
- Store your API key in a `.env` file for security reasons.
- Use the `dotenv` package to load environment variables into your Node.js app.

4. API Call:
- Use `axios` or `node-fetch` to make the API request to fetch the weather data.

Submission:
● Submit the project as a zipped folder.
● The project should include a README.md file with instructions on how to run the
application, install dependencies, and how to obtain an API key for the weather
API.

You might also like