We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 060f454 commit f721b4eCopy full SHA for f721b4e
1 file changed
0x11-python-network_1/7-error_code.py
@@ -0,0 +1,18 @@
1
+#!/usr/bin/python3
2
+'''
3
+That takes in a URL, sends a request to the URL
4
+and displays the body of the response.
5
6
+import requests
7
+import sys
8
+
9
+if __name__ == "__main__":
10
+ response = requests.get(sys.argv[1])
11
+ stat_code = response.status_code
12
+ if stat_code > 400:
13
+ print('Error code: {}'.format(stat_code))
14
+ else:
15
+ print('{}'.format(response.text))
16
17
18
0 commit comments