diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..342bf368 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +.venv +README.md +result.png +.github +checklist.md \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..c887a695 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM python:3.9-slim +LABEL maintainer="vladrymarchuk@gmai.com" + + +WORKDIR /app + +COPY requirements.txt requirements.txt +RUN pip install -r requirements.txt + +COPY app/main.py /app + +CMD ["python", "main.py"] diff --git a/app/main.py b/app/main.py index 16dd4058..1243fd30 100644 --- a/app/main.py +++ b/app/main.py @@ -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") + 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}") if __name__ == "__main__": diff --git a/requirements.txt b/requirements.txt index 03c40c25..2b962ba8 100644 Binary files a/requirements.txt and b/requirements.txt differ