Ramzan0553's picture
Create app.py
f9793f4 verified
raw
history blame contribute delete
766 Bytes
import gradio as gr
import speedtest
# Function to check internet speed
def check_speed():
try:
st = speedtest.Speedtest()
st.get_best_server()
download_speed = st.download() / 1_000_000 # Convert to Mbps
upload_speed = st.upload() / 1_000_000 # Convert to Mbps
result = f"📥 Download Speed: {download_speed:.2f} Mbps\n📤 Upload Speed: {upload_speed:.2f} Mbps"
return result
except Exception as e:
return f"⚠️ Error: {str(e)}"
# Gradio UI
iface = gr.Interface(
fn=check_speed,
inputs=[],
outputs="text",
title="🌐 Internet Speed Test",
description="Click the button below to test your internet speed.",
live=True
)
if __name__ == "__main__":
iface.launch()