mirror of
https://github.com/metafy-social/python-scripts.git
synced 2025-02-07 09:00:58 +00:00
Merge pull request #137 from Icelain/master
Removed plain api keys from Weather-teller and Weather_Reports and added environment variable support in their place
This commit is contained in:
commit
86a48a27c6
1
scripts/Weather-teller/.env.example
Normal file
1
scripts/Weather-teller/.env.example
Normal file
|
@ -0,0 +1 @@
|
||||||
|
WEATHER_MAP_API_KEY=XXXXXXXXX
|
1
scripts/Weather-teller/requirements.txt
Normal file
1
scripts/Weather-teller/requirements.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
python-dotenv
|
|
@ -1,7 +1,10 @@
|
||||||
import requests
|
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"
|
BASE_URL = "http://api.openweathermap.org/data/2.5/weather"
|
||||||
|
|
||||||
city = input("enter a city name: ")
|
city = input("enter a city name: ")
|
||||||
|
|
1
scripts/Weather_Reports/.env.example
Normal file
1
scripts/Weather_Reports/.env.example
Normal file
|
@ -0,0 +1 @@
|
||||||
|
WEATHER_API_KEY=XXXXXXXX
|
1
scripts/Weather_Reports/requirements.txt
Normal file
1
scripts/Weather_Reports/requirements.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
python-dotenv
|
|
@ -1,12 +1,19 @@
|
||||||
import requests
|
import requests
|
||||||
import json
|
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 : "))
|
loc = str(input("Enter Location : "))
|
||||||
url = "https://weatherapi-com.p.rapidapi.com/current.json"
|
url = "https://weatherapi-com.p.rapidapi.com/current.json"
|
||||||
|
|
||||||
querystring = {"q":loc}
|
querystring = {"q":loc}
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
"X-RapidAPI-Key": "bdfb49f730mshb9aca5467ecee49p121eeajsn6be212dbf15d",
|
"X-RapidAPI-Key": WEATHER_API_KEY,
|
||||||
"X-RapidAPI-Host": "weatherapi-com.p.rapidapi.com"
|
"X-RapidAPI-Host": "weatherapi-com.p.rapidapi.com"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user