Add lambda function to write json to dynamo db
This commit is contained in:
@@ -6,9 +6,11 @@ import logging
|
||||
|
||||
class WheatherAPI():
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, bucket_name, folder_name):
|
||||
self.current_url = 'http://api.weatherapi.com/v1/current.json?key=6b0654bd658842b085395550230406&q=location&aqi=no'
|
||||
self.forecast_url = 'http://api.weatherapi.com/v1/forecast.json?key=6b0654bd658842b085395550230406&q=location&days=no_days&aqi=no&alerts=no'
|
||||
self.bucket_name = bucket_name
|
||||
self.folder_name = folder_name
|
||||
|
||||
def current_wheather(self, location):
|
||||
|
||||
@@ -20,9 +22,11 @@ class WheatherAPI():
|
||||
|
||||
filename = 'current_' + location + '_' + datetime.now().strftime('%Y-%m-%d-%H-%M') + '.json'
|
||||
|
||||
with open(os.path.join('C:/Users/jacob/PycharmProjects/AWS-Training/results/current', filename) ,'w') as file: #/results/current/
|
||||
with open(os.path.join('C:/Users/jacob/PycharmProjects/GCP-Weather-Forecast/current', filename) ,'w') as file: #/results/current/
|
||||
json.dump(data, file)
|
||||
|
||||
|
||||
|
||||
def forecast_wheather(self, location, no_days):
|
||||
|
||||
url = self.forecast_url.replace('location', location)
|
||||
@@ -34,7 +38,7 @@ class WheatherAPI():
|
||||
|
||||
filename = 'forecasts_' + location + '_' + str(no_days) + '_' + datetime.now().strftime('%Y-%m-%d-%H-%M') + '.json'
|
||||
|
||||
with open(os.path.join('C:/Users/jacob/PycharmProjects/AWS-Training/results/forecasts', filename), 'w') as file: #/results/forecasts/
|
||||
with open(os.path.join('C:/Users/jacob/PycharmProjects/GCP-Weather-Forecast/forecasts', filename), 'w') as file: #/results/forecasts/
|
||||
json.dump(data, file)
|
||||
|
||||
def call_current_wheater(self, last_datetime, location_list):
|
||||
|
||||
Reference in New Issue
Block a user