Skip to content

Commit

Permalink
Add weather data retrieval and display functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
frezworx committed Jan 10, 2025
1 parent fc944ab commit ebe2f19
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM python:3.12.8-alpine3.20
LABEL authors="frezworx"

ENV PYTHONUNBUFFERED=1

WORKDIR /app

COPY requirements.txt requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

CMD ["python", "app/main.py"]
19 changes: 17 additions & 2 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import os
from pprint import pprint

from dotenv import load_dotenv

import requests
Expand All @@ -11,9 +13,22 @@


def get_weather() -> None:
print(API_KEY)
print(f"Performing request to Weather API for city {FILTERING}...")
response = requests.get(f"{URL}current.json?key={API_KEY}&q={FILTERING}")
print(response.json())
data = response.json()

location = data.get("location", {})
current = data.get("current", {})

city = location.get("name", "")
country = location.get("country", "")
date = location.get("localtime", "")
temperature = current.get("temp_c", "")
condition = current.get("condition", {}).get("text", "")

print(
f"{city}/{country} {date} Weather: {temperature} Celsius, {condition}"
)


if __name__ == "__main__":
Expand Down

0 comments on commit ebe2f19

Please sign in to comment.