Skip to content

Commit 004c109

Browse files
committed
Check_website_connectivity/check_connectivity.py: create main()
Embed the actual functionality in a separate function so other code can import this PEP8 up the imports Don't print
1 parent 56a4a91 commit 004c109

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
1-
import requests
21
import csv
32

3+
import requests
4+
5+
46
status_dict = {"Website": "Status"}
57

6-
if __name__ == "__main__":
78

9+
def main():
810
with open("websites.txt", "r") as fr:
911
for line in fr:
1012
status = requests.get(line.strip()).status_code
1113
status_dict[line] = "working" if status == 200 else "not working"
1214

13-
print(status_dict)
15+
# print(status_dict)
1416
with open("website_status.csv", "w", newline="") as fw:
1517
csv_writers = csv.writer(fw)
1618
for key in status_dict.keys():
1719
csv_writers.writerow([key, status_dict[key]])
20+
21+
22+
if __name__ == "__main__":
23+
main()

0 commit comments

Comments
 (0)