api keys for weather-teller and weather_reports are now loaded from a local .env file

This commit is contained in:
icelain 2022-10-05 11:49:29 +05:30
parent 20699af3a5
commit 4000926ef8
2 changed files with 13 additions and 3 deletions

View File

@ -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: ")

View File

@ -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"
)
)