Nottybro commited on
Commit
0e4ff68
·
verified ·
1 Parent(s): 8befb68

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import requests
3
+ import gradio as gr
4
+
5
+ def get_ip():
6
+ try:
7
+ ip = requests.get("https://ifconfig.me", timeout=10).text.strip()
8
+ except Exception as e:
9
+ ip = f"Error: {e}"
10
+ return ip
11
+
12
+ # Fetch at startup so it's immediately visible in logs
13
+ MY_IP = get_ip()
14
+ print(f"\n{'='*40}")
15
+ print(f" PUBLIC IP: {MY_IP}")
16
+ print(f"{'='*40}\n")
17
+
18
+ with gr.Blocks() as demo:
19
+ gr.Markdown("## IP Reporter")
20
+ ip_box = gr.Textbox(label="Public outbound IP of this Space", value=MY_IP)
21
+ refresh = gr.Button("Refresh")
22
+ refresh.click(fn=get_ip, outputs=ip_box)
23
+
24
+ demo.launch()