Created
December 16, 2020 15:11
-
-
Save kachina/8515ab2fac91022690eb49b356943e55 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 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" % ( | |
os.getenv('OWM_PLACE'), | |
observation.weather.status | |
)) | |
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