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 #692

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.venv
README.md
result.png
.github
checklist.md
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM python:3.9-slim
LABEL maintainer="[email protected]"

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'.

Choose a reason for hiding this comment

The 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

Choose a reason for hiding this comment

The 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.

Choose a reason for hiding this comment

The 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

Choose a reason for hiding this comment

The 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.

Choose a reason for hiding this comment

The 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"]
23 changes: 21 additions & 2 deletions app/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")

Choose a reason for hiding this comment

The 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}")

Choose a reason for hiding this comment

The 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__":
Expand Down
Binary file modified requirements.txt
Binary file not shown.
Loading