forked from shahsamkit/python-github-action-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
26 lines (21 loc) · 713 Bytes
/
main.py
File metadata and controls
26 lines (21 loc) · 713 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import logging
import logging.handlers
import requests
# Setup logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logger_file_handler = logging.handlers.RotatingFileHandler(
"status.log",
maxBytes=1024 * 1024,
backupCount=1,
encoding="utf8",
)
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
logger_file_handler.setFormatter(formatter)
logger.addHandler(logger_file_handler)
if __name__ == "__main__":
r = requests.get('https://goweather.herokuapp.com/weather/austin')
if r.status_code == 200:
data = r.json()
temperature = data['temperature']
logger.info(f'Weather in Austin: {temperature}')