Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution #690

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Solution #690

wants to merge 4 commits into from

Conversation

frezworx
Copy link

ss_1

- Import `requests` module
- Define constants for API URL, API key, and filtering location
- Implement `get_weather` function to fetch and print current weather data
Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job on your submission! 🎉 The code meets most of the task requirements and constraints. While there are a few areas for improvement, such as adding error handling for unsuccessful requests and ensuring the API_KEY is set, these are minor and don't impact the core functionality. Keep up the good work and consider the feedback for future enhancements! 😊

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨


WORKDIR /app

COPY requirements.txt requirements.txt

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider copying only the necessary files for installing dependencies first, such as COPY requirements.txt ., before copying the entire context. This can help leverage Docker's caching mechanism more effectively.

COPY requirements.txt requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that the COPY . . command does not unintentionally include files that are not needed in the Docker image. Verify that your .dockerignore file is correctly configured to exclude unnecessary files.


load_dotenv()
URL = "https://api.weatherapi.com/v1/"
API_KEY = os.getenv("API_KEY")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that the API_KEY environment variable is set correctly. If it's not set, the script will fail to authenticate with the Weather API. Consider adding a check to handle the case where API_KEY is None.

# write your code here
pass
print(f"Performing request to Weather API for city {FILTERING}...")
response = requests.get(f"{URL}current.json?key={API_KEY}&q={FILTERING}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good practice to check the status code of the response to ensure the request was successful before attempting to parse the JSON data. Consider adding error handling for unsuccessful requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants