Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,9 @@ from pathlib import Path
|
|
7 |
from moviepy.editor import VideoFileClip
|
8 |
import gradio as gr
|
9 |
from gradio import components
|
|
|
|
|
|
|
10 |
|
11 |
# Define output directory
|
12 |
output_dir = Path.cwd() / "output"
|
@@ -21,6 +24,13 @@ quality_mapping = {
|
|
21 |
"High": 18,
|
22 |
}
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
def download_file(url, destination):
|
25 |
response = requests.get(url)
|
26 |
response.raise_for_status()
|
@@ -92,8 +102,7 @@ def convert_video(video_file, quality, aspect_ratio, video_url):
|
|
92 |
# After generating the video files, create links to them
|
93 |
output_links = []
|
94 |
for path in output_paths:
|
95 |
-
output_links.append(f'<a href="{path}" target="_blank">Download {Path(path).stem}</a>')
|
96 |
-
|
97 |
output_html = "<br>".join(output_links)
|
98 |
return output_html
|
99 |
|
@@ -115,4 +124,5 @@ interface = gradio.Interface(
|
|
115 |
allow_flagging=False
|
116 |
)
|
117 |
|
|
|
118 |
interface.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
7 |
from moviepy.editor import VideoFileClip
|
8 |
import gradio as gr
|
9 |
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"
|
|
|
24 |
"High": 18,
|
25 |
}
|
26 |
|
27 |
+
def start_http_server(port=8000):
|
28 |
+
handler = http.server.SimpleHTTPRequestHandler
|
29 |
+
httpd = socketserver.TCPServer(("", port), handler)
|
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)
|
36 |
response.raise_for_status()
|
|
|
102 |
# After generating the video files, create links to them
|
103 |
output_links = []
|
104 |
for path in output_paths:
|
105 |
+
output_links.append(f'<a href="http://your_server_ip:{http_server_port}/{path}" target="_blank">Download {Path(path).stem}</a>')
|
|
|
106 |
output_html = "<br>".join(output_links)
|
107 |
return output_html
|
108 |
|
|
|
124 |
allow_flagging=False
|
125 |
)
|
126 |
|
127 |
+
start_http_server(http_server_port)
|
128 |
interface.launch(server_name="0.0.0.0", server_port=7860)
|