From b6907d4e2261e853874bcd3231430c4ae13e1975 Mon Sep 17 00:00:00 2001 From: Olevksy Ivan Date: Wed, 11 Dec 2024 16:12:53 +0200 Subject: [PATCH] solution --- .dockerignore | 1 + Dockerfile | 11 +++++++++++ app/main.py | 19 +++++++++++++++++-- requirements.txt | 1 + 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..b694934f --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +.venv \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..c16537ee --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM python:3.11 + +WORKDIR /app + +COPY requirements.txt . + +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . + +CMD ["python", "app/main.py"] diff --git a/app/main.py b/app/main.py index 16dd4058..56bf3e11 100644 --- a/app/main.py +++ b/app/main.py @@ -1,6 +1,21 @@ +import requests +import os + +API_KEY = os.getenv("API_KEY") +city = "Paris" + + def get_weather() -> None: - # write your code here - pass + url = ( + f"http:" + f"//api.weatherapi.com/v1/current.json?key={API_KEY}" + f"&q={city}&aqi=no" + ) + response = requests.get(url) + + if response.status_code == 200: + data = response.json() + print(f"Weather in {city}: {data['current']['temp_c']}°C") if __name__ == "__main__": diff --git a/requirements.txt b/requirements.txt index 03c40c25..dc6d0d3b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ flake8-annotations==2.9.1 flake8-quotes==3.3.1 flake8-variables-names==0.0.5 pep8-naming==0.13.2 +requests \ No newline at end of file