-
Notifications
You must be signed in to change notification settings - Fork 681
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 #692
base: master
Are you sure you want to change the base?
solution #692
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.venv | ||
README.md | ||
result.png | ||
.github | ||
checklist.md |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM python:3.9-slim | ||
LABEL maintainer="[email protected]" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a typo in the email address in the LABEL instruction. It should be corrected from 'gmai.com' to 'gmail.com'. |
||
|
||
|
||
WORKDIR /app | ||
|
||
COPY requirements.txt requirements.txt | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The COPY command should specify the source path relative to the Docker build context. Ensure that 'requirements.txt' is in the same directory as the Dockerfile or adjust the path accordingly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure that the 'requirements.txt' file is in the correct location relative to the Docker build context. If the file is not found, the build will fail. |
||
RUN pip install -r requirements.txt | ||
|
||
COPY app/main.py /app | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The COPY command should specify the source path relative to the Docker build context. Ensure that 'app/main.py' is in the correct location relative to the Dockerfile or adjust the path accordingly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure that the path 'app/main.py' is correct relative to the Docker build context. If the file is not in the expected location, the build will fail. |
||
|
||
CMD ["python", "main.py"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,25 @@ | ||
import os | ||
|
||
import requests | ||
|
||
|
||
def get_weather() -> None: | ||
# write your code here | ||
pass | ||
api_key = os.getenv("API_KEY", "No API key provided") | ||
city = os.getenv("CITY", "Kyiv") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default city should be 'Paris' as per the task requirements. Please update the default value from 'Kyiv' to 'Paris'. |
||
url = (f"https://api.weatherapi.com/v1/current.json?key=" | ||
f"{api_key}&q={city}&aqi=no") | ||
response = requests.get(url) | ||
if response.status_code == 200: | ||
weather_data = response.json() | ||
weather_data = ( | ||
weather_data["location"]["country"], | ||
weather_data["location"]["name"], | ||
weather_data["location"]["localtime"], | ||
f"Weather: {weather_data['current']['temp_c']} Celsius", | ||
weather_data["current"]["condition"]["text"]) | ||
print(weather_data) | ||
else: | ||
print(f"Error: {response.status_code}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be helpful to include more detailed error handling here. For example, you could print the response text or provide more context about the failure to help with debugging. |
||
|
||
|
||
if __name__ == "__main__": | ||
|
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.
There is a typo in the email address in the LABEL instruction. It should be 'gmail.com' instead of 'gmai.com'.