raannakasturi commited on
Commit
a6b8177
1 Parent(s): 930eb8a

Update getStatus.py

Browse files
Files changed (1) hide show
  1. getStatus.py +44 -44
getStatus.py CHANGED
@@ -1,45 +1,45 @@
1
- import json
2
-
3
- def run(code):
4
- code, webstatus, status, morestatus = getStatus(code)
5
- return code, webstatus, status, morestatus
6
-
7
- def getStatus(code):
8
- with open('./status.json', 'r') as file:
9
- data = json.load(file)
10
- try:
11
- if code.startswith("2"):
12
- status = data['WebStatus']['Online']['SuccessfulConnection'][code]
13
- code = code
14
- webstatus = "Online"
15
- status = status
16
- morestatus = f"The website is currently functioning optimally and delivering content successfully."
17
- return code, webstatus, status, morestatus
18
- elif code.startswith("3"):
19
- status = data['WebStatus']['Online']['Redirection'][code]
20
- code = code
21
- webstatus = "Online"
22
- status = status
23
- morestatus = f"The website is employing a redirection mechanism to direct users to a different URL (Redirection code: {code})."
24
- return code, webstatus, status, morestatus
25
- elif code.startswith("4"):
26
- status = data['WebStatus']['Offline']['ClientError'][code]
27
- code = code
28
- webstatus = "Offline. Client-side Error or Unauthorization Error or Authentication Error."
29
- status = status
30
- morestatus = f"Website is offline due to a client-side error (Client Error code: {code}). This could be caused by an invalid request or issue with your browser."
31
- return code, webstatus, status, morestatus
32
- elif code.startswith("5"):
33
- status = data['WebStatus']['Offline']['ServerError'][code]
34
- code = code
35
- webstatus = "Offline"
36
- status = status
37
- morestatus = f"Website is offline due to a server-side error (Server Error code: {code}). This indicates an issue with the website itself or its infrastructure."
38
- return code, webstatus, status, morestatus
39
- else:
40
- return "Invalid status code. Please contact us for assistance.", "Invalid status code. Please contact us for assistance.", "Invalid status code. Please contact us for assistance.", "Invalid status code. Please contact us for assistance."
41
- except KeyError:
42
- return "abc.", "def.", "ghi.", "jkl."
43
-
44
- if __name__ == "__main__":
45
  run()
 
1
+ import json
2
+
3
+ def run(code):
4
+ code, webstatus, status, morestatus = getStatus(code)
5
+ return code, webstatus, status, morestatus
6
+
7
+ def getStatus(code):
8
+ with open('/home/user/app/status.json', 'r') as file:
9
+ data = json.load(file)
10
+ try:
11
+ if code.startswith("2"):
12
+ status = data['WebStatus']['Online']['SuccessfulConnection'][code]
13
+ code = code
14
+ webstatus = "Online"
15
+ status = status
16
+ morestatus = f"The website is currently functioning optimally and delivering content successfully."
17
+ return code, webstatus, status, morestatus
18
+ elif code.startswith("3"):
19
+ status = data['WebStatus']['Online']['Redirection'][code]
20
+ code = code
21
+ webstatus = "Online"
22
+ status = status
23
+ morestatus = f"The website is employing a redirection mechanism to direct users to a different URL (Redirection code: {code})."
24
+ return code, webstatus, status, morestatus
25
+ elif code.startswith("4"):
26
+ status = data['WebStatus']['Offline']['ClientError'][code]
27
+ code = code
28
+ webstatus = "Offline. Client-side Error or Unauthorization Error or Authentication Error."
29
+ status = status
30
+ morestatus = f"Website is offline due to a client-side error (Client Error code: {code}). This could be caused by an invalid request or issue with your browser."
31
+ return code, webstatus, status, morestatus
32
+ elif code.startswith("5"):
33
+ status = data['WebStatus']['Offline']['ServerError'][code]
34
+ code = code
35
+ webstatus = "Offline"
36
+ status = status
37
+ morestatus = f"Website is offline due to a server-side error (Server Error code: {code}). This indicates an issue with the website itself or its infrastructure."
38
+ return code, webstatus, status, morestatus
39
+ else:
40
+ return "Invalid status code. Please contact us for assistance.", "Invalid status code. Please contact us for assistance.", "Invalid status code. Please contact us for assistance.", "Invalid status code. Please contact us for assistance."
41
+ except KeyError:
42
+ return "abc.", "def.", "ghi.", "jkl."
43
+
44
+ if __name__ == "__main__":
45
  run()