-
Notifications
You must be signed in to change notification settings - Fork 678
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
base: master
Are you sure you want to change the base?
Solution #690
Conversation
frezworx
commented
Jan 10, 2025
- Import `requests` module - Define constants for API URL, API key, and filtering location - Implement `get_weather` function to fetch and print current weather data
There was a problem hiding this 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 |
There was a problem hiding this comment.
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 . . |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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}") |
There was a problem hiding this comment.
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.