File size: 766 Bytes
f9793f4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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()