From 4000926ef8e7c7aa48954b3699c7566a355eaed7 Mon Sep 17 00:00:00 2001 From: icelain Date: Wed, 5 Oct 2022 11:49:29 +0530 Subject: [PATCH 1/3] api keys for weather-teller and weather_reports are now loaded from a local .env file --- scripts/Weather-teller/weather-det.py | 5 ++++- scripts/Weather_Reports/script.py | 11 +++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/scripts/Weather-teller/weather-det.py b/scripts/Weather-teller/weather-det.py index 82bdf47..219e100 100644 --- a/scripts/Weather-teller/weather-det.py +++ b/scripts/Weather-teller/weather-det.py @@ -1,7 +1,10 @@ import requests +import os +from dotenv import load_dotenv +load_dotenv() -API_KEY = "b09dc0e32c95634996021e1c49d7a751" +API_KEY = os.environ.get("WEATHER_MAP_API_KEY") BASE_URL = "http://api.openweathermap.org/data/2.5/weather" city = input("enter a city name: ") diff --git a/scripts/Weather_Reports/script.py b/scripts/Weather_Reports/script.py index 7ad26b0..e4bcab5 100644 --- a/scripts/Weather_Reports/script.py +++ b/scripts/Weather_Reports/script.py @@ -1,12 +1,19 @@ import requests import json +import os +from dotenv import load_dotenv + +load_dotenv() + +WEATHER_API_KEY = os.environ.get("WEATHER_API_KEY") + loc = str(input("Enter Location : ")) url = "https://weatherapi-com.p.rapidapi.com/current.json" querystring = {"q":loc} headers = { - "X-RapidAPI-Key": "bdfb49f730mshb9aca5467ecee49p121eeajsn6be212dbf15d", + "X-RapidAPI-Key": WEATHER_API_KEY, "X-RapidAPI-Host": "weatherapi-com.p.rapidapi.com" } @@ -27,4 +34,4 @@ print( "Wind Degree : " , y["current"]["wind_degree"], "°\n", "Wind Direction : " , y["current"]["wind_dir"], "\n", "------------------------------------------\n" -) \ No newline at end of file +) From b6a8263b03ee08b1a764c199a0f9f686dfb8ce6c Mon Sep 17 00:00:00 2001 From: icelain Date: Wed, 5 Oct 2022 11:54:05 +0530 Subject: [PATCH 2/3] added requirements.txt with python-dotenv --- scripts/Weather-teller/requirements.txt | 1 + scripts/Weather_Reports/requirements.txt | 1 + 2 files changed, 2 insertions(+) create mode 100644 scripts/Weather-teller/requirements.txt create mode 100644 scripts/Weather_Reports/requirements.txt diff --git a/scripts/Weather-teller/requirements.txt b/scripts/Weather-teller/requirements.txt new file mode 100644 index 0000000..566cccb --- /dev/null +++ b/scripts/Weather-teller/requirements.txt @@ -0,0 +1 @@ +python-dotenv diff --git a/scripts/Weather_Reports/requirements.txt b/scripts/Weather_Reports/requirements.txt new file mode 100644 index 0000000..566cccb --- /dev/null +++ b/scripts/Weather_Reports/requirements.txt @@ -0,0 +1 @@ +python-dotenv From c107abfed377082d95568b49d902de79a62c3d6e Mon Sep 17 00:00:00 2001 From: icelain Date: Wed, 5 Oct 2022 12:38:55 +0530 Subject: [PATCH 3/3] added .env.example files for Weather-teller and Weather_Reports --- scripts/Weather-teller/.env.example | 1 + scripts/Weather_Reports/.env.example | 1 + 2 files changed, 2 insertions(+) create mode 100644 scripts/Weather-teller/.env.example create mode 100644 scripts/Weather_Reports/.env.example diff --git a/scripts/Weather-teller/.env.example b/scripts/Weather-teller/.env.example new file mode 100644 index 0000000..4bbb28c --- /dev/null +++ b/scripts/Weather-teller/.env.example @@ -0,0 +1 @@ +WEATHER_MAP_API_KEY=XXXXXXXXX diff --git a/scripts/Weather_Reports/.env.example b/scripts/Weather_Reports/.env.example new file mode 100644 index 0000000..07f9b26 --- /dev/null +++ b/scripts/Weather_Reports/.env.example @@ -0,0 +1 @@ +WEATHER_API_KEY=XXXXXXXX