Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -10,6 +10,7 @@ from gradio import components
|
|
10 |
import http.server
|
11 |
import socketserver
|
12 |
import threading
|
|
|
13 |
|
14 |
# Define output directory
|
15 |
output_dir = Path.cwd() / "output"
|
@@ -30,6 +31,22 @@ def start_http_server(port=8000):
|
|
30 |
logging.info(f"Serving at port {port}")
|
31 |
thread = threading.Thread(target=httpd.serve_forever)
|
32 |
thread.start()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
def download_file(url, destination):
|
35 |
response = requests.get(url)
|
@@ -106,6 +123,11 @@ def convert_video(video_file, quality, aspect_ratio, video_url):
|
|
106 |
output_html = "<br>".join(output_links)
|
107 |
return output_html
|
108 |
|
|
|
|
|
|
|
|
|
|
|
109 |
# Change "video" to "file"
|
110 |
video_file = gradio.inputs.File(label="Your video file")
|
111 |
quality = gradio.inputs.Slider(minimum=1, maximum=50, default=25, label="Quality (1:Speed - 50:Quality)")
|
|
|
10 |
import http.server
|
11 |
import socketserver
|
12 |
import threading
|
13 |
+
import socket
|
14 |
|
15 |
# Define output directory
|
16 |
output_dir = Path.cwd() / "output"
|
|
|
31 |
logging.info(f"Serving at port {port}")
|
32 |
thread = threading.Thread(target=httpd.serve_forever)
|
33 |
thread.start()
|
34 |
+
|
35 |
+
def get_ip_address():
|
36 |
+
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
37 |
+
try:
|
38 |
+
# doesn't have to be reachable
|
39 |
+
s.connect(('10.255.255.255', 1))
|
40 |
+
IP = s.getsockname()[0]
|
41 |
+
except Exception:
|
42 |
+
IP = '127.0.0.1'
|
43 |
+
finally:
|
44 |
+
s.close()
|
45 |
+
return IP
|
46 |
+
|
47 |
+
def get_public_ip_address():
|
48 |
+
response = requests.get('https://httpbin.org/ip')
|
49 |
+
return response.json()['origin']
|
50 |
|
51 |
def download_file(url, destination):
|
52 |
response = requests.get(url)
|
|
|
123 |
output_html = "<br>".join(output_links)
|
124 |
return output_html
|
125 |
|
126 |
+
server_ip = get_ip_address() # or get_public_ip_address() if you need the public IP
|
127 |
+
for path in output_paths:
|
128 |
+
# Replace 'your_server_ip' with server_ip
|
129 |
+
output_links.append(f'<a href="http://{server_ip}:8000/{path}" target="_blank">Download {Path(path).stem}</a>')
|
130 |
+
|
131 |
# Change "video" to "file"
|
132 |
video_file = gradio.inputs.File(label="Your video file")
|
133 |
quality = gradio.inputs.Slider(minimum=1, maximum=50, default=25, label="Quality (1:Speed - 50:Quality)")
|