Created
December 16, 2020 15:13
-
-
Save kachina/9b35863759a593cdb8f71a0f999489a8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import os | |
import pkg_resources | |
import pyowm | |
# 開発環境の場合は .env ファイルを読み込む | |
for dist in pkg_resources.working_set: | |
if dist.project_name == 'python-dotenv': | |
from dotenv import load_dotenv | |
load_dotenv() | |
owm = pyowm.OWM(os.getenv('OWM_API_KEY')) | |
def lambda_handler(event, context): | |
observation = owm.weather_manager().weather_at_place(os.getenv('OWM_PLACE')) | |
print("%s - Current Weather: %s (%s)" % ( | |
os.getenv('OWM_PLACE'), | |
observation.weather.status, | |
datetime.datetime.now() | |
)) | |
if __name__ == "__main__": | |
lambda_handler(None, None) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment