COLTO50 commited on
Commit
8fb6e99
·
verified ·
1 Parent(s): cb7a5ba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py CHANGED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ pip install gradio requests
2
+
3
+ # Create the Gradio application
4
+ cat > app.py << EOL
5
+ import gradio as gr
6
+ import requests
7
+ import concurrent.futures
8
+
9
+ def open_links(link, count):
10
+ def open_link(url):
11
+ try:
12
+ response = requests.get(url)
13
+ return response.status_code
14
+ except:
15
+ return 'Error'
16
+
17
+ results = []
18
+ with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
19
+ futures = [executor.submit(open_link, link) for _ in range(count)]
20
+ for future in concurrent.futures.as_completed(futures):
21
+ results.append(str(future.result()))
22
+
23
+ return "\n".join(results)
24
+
25
+ iface = gr.Interface(
26
+ fn=open_links,
27
+ inputs=[
28
+ gr.Textbox(label="Enter link"),
29
+ gr.Slider(minimum=1, maximum=100, step=1, label="Number of times to open")
30
+ ],
31
+ outputs="text",
32
+ title="Link Opener",
33
+ description="Enter a link and choose how many times to open it.",
34
+ theme="huggingface",
35
+ examples=[["https://www.example.com", 5]]
36
+ )
37
+
38
+ iface.launch()