We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 002cebb + 0960a5d commit 8f703bbCopy full SHA for 8f703bb
1 file changed
wttr.py
@@ -0,0 +1,38 @@
1
+"""
2
+::@name Get Weather for a city and display it in the console
3
+
4
+::@description
5
+ Takes input for city. Gives output of weather for a city in a text format.
6
+ Command arg -c City
7
+::@/description
8
9
10
+import argparse
11
+import requests
12
13
14
+PARSER = argparse.ArgumentParser()
15
16
+PARSER.add_argument(
17
+ "-c",
18
+ "--city",
19
+ dest="city",
20
+ default="Christchurch",
21
+ help="Name of the City to display weather info from wttr.in",
22
+)
23
24
25
+ARGS = PARSER.parse_args()
26
27
+CITY = ARGS.city
28
29
30
+def get_weather():
31
+ """Display Weather for city in console"""
32
+ url = f"https://wttr.in/{CITY}"
33
+ response = requests.get(url=url, timeout=None)
34
+ print(response.text)
35
36
37
+if __name__ == "__main__":
38
+ get_weather()
0 commit comments