Skip to content

Commit 1e6eb0f

Browse files
Merge pull request #2796 from smty2018/httpstatus
Website Status Checker GUI
2 parents 822c50f + fb29c49 commit 1e6eb0f

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

Website Status Checker GUI/ReadMe.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Description:
2+
Creates a graphical user interface (GUI) application that allows users to check the status of websites.
3+
Users can input a website URL into the provided entry field and click the
4+
"Check Website" button to instantly retrieve the HTTP status code and description of the website's response.
5+
6+
Retrieves the HTTP status code and description of the website's response.
7+
Utilizes the urlopen function to send HTTP requests and retrieve responses.
8+
Utilizes the http.HTTPStatus enumeration to map status codes to their descriptions
9+
10+
Requrements(ignore if installed):
11+
12+
pip install tkinter
13+
pip install urllib3
14+
pip install http
15+
pip install fake-useragent
16+
17+
Output:
18+
19+
![Screenshot 2023-08-10 043300](https://github.com/smty2018/Amazing-Python-Scripts/assets/74114936/0cc2c6d9-757d-4bdf-b390-47853f422dca)
20+
21+
Steps to run:
22+
1. cd Website Status Checker GUI
23+
2. python app.py
24+

Website Status Checker GUI/app.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import tkinter as tk
2+
from urllib.request import urlopen
3+
from http import HTTPStatus
4+
from fake_useragent import UserAgent
5+
6+
def get_status(status_code: int) -> str:
7+
for value in HTTPStatus:
8+
if value.value == status_code:
9+
description = f'({value.value} {value.name}) {value.description}'
10+
return description
11+
return "Unknown Status Code..."
12+
13+
def check_website():
14+
website_url = website_entry.get()
15+
result_text.delete("1.0", tk.END)
16+
17+
try:
18+
response = urlopen(website_url)
19+
status_code = response.getcode()
20+
status_description = get_status(status_code)
21+
result = f"Status for {website_url}:\n{status_description}\n"
22+
except Exception as e:
23+
result = f"Error checking {website_url}:\n{str(e)}\n"
24+
25+
result_text.insert(tk.END, result)
26+
27+
root = tk.Tk()
28+
root.title("Website Checker")
29+
root.configure(bg="#1e1e1e")
30+
31+
website_label = tk.Label(root, text="Enter Website URL:", bg="#1e1e1e", fg="white")
32+
website_label.pack(pady=5)
33+
34+
website_entry = tk.Entry(root, width=50)
35+
website_entry.pack(pady=5)
36+
37+
check_button = tk.Button(root, text="Check Website", command=check_website, bg="#303030", fg="white")
38+
check_button.pack(pady=5)
39+
40+
result_text = tk.Text(root, wrap=tk.WORD, bg="#1e1e1e", fg="white")
41+
result_text.pack(fill=tk.BOTH, expand=True)
42+
43+
root.mainloop()

0 commit comments

Comments
 (0)