Skip to content

Commit 17bb2fe

Browse files
Initial commit: Internet Speed Test App
0 parents  commit 17bb2fe

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

InternetSpeedTestApp/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Internet Speed Test App
2+
3+
## Features
4+
- CLI and GUI versions of an internet speed test application.
5+
- Uses `speedtest-cli` to measure download, upload speeds and ping.
6+
7+
## How to Use
8+
9+
### Install Requirements
10+
```bash
11+
pip install -r requirements.txt
12+
```
13+
14+
### Run CLI Version
15+
```bash
16+
python speed_test_cli.py
17+
```
18+
19+
### Run GUI Version
20+
```bash
21+
python speed_test_gui.py
22+
```
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
speedtest-cli
2+
speedtest-cli
3+
requests
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import speedtest
2+
import socket
3+
import requests
4+
5+
def get_local_ip():
6+
try:
7+
return socket.gethostbyname(socket.gethostname())
8+
except:
9+
return "Unavailable"
10+
11+
def get_external_ip_and_isp():
12+
try:
13+
response = requests.get("https://ipinfo.io/json")
14+
data = response.json()
15+
return data.get("ip", "N/A"), data.get("org", "N/A"), data.get("city", "N/A"), data.get("country", "N/A")
16+
except:
17+
return "N/A", "N/A", "N/A", "N/A"
18+
19+
def main():
20+
print("🔍 Getting network details...\n")
21+
local_ip = get_local_ip()
22+
external_ip, isp, city, country = get_external_ip_and_isp()
23+
24+
print(f"📡 Local IP Address : {local_ip}")
25+
print(f"🌐 External IP Address : {external_ip}")
26+
print(f"🏢 ISP : {isp}")
27+
print(f"📍 Location : {city}, {country}\n")
28+
29+
st = speedtest.Speedtest()
30+
31+
print("🔎 Finding best server...")
32+
best = st.get_best_server()
33+
print(f"✅ Best Server Found: {best['host']} ({best['name']}, {best['country']})\n")
34+
35+
print("⚡ Testing download speed...")
36+
download_speed = st.download() / 1_000_000
37+
38+
print("⚡ Testing upload speed...")
39+
upload_speed = st.upload() / 1_000_000
40+
41+
ping = st.results.ping
42+
43+
print("\n📊 Speed Test Results:")
44+
print(f"⬇️ Download Speed : {download_speed:.2f} Mbps")
45+
print(f"⬆️ Upload Speed : {upload_speed:.2f} Mbps")
46+
print(f"⏱ Ping : {ping:.2f} ms")
47+
48+
print(f"\n🔗 Result Share Link : {st.results.share()}")
49+
50+
if __name__ == "__main__":
51+
main()

0 commit comments

Comments
 (0)