Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ import traceback
|
|
4 |
import uuid
|
5 |
import glob
|
6 |
import os
|
|
|
7 |
import asyncio
|
8 |
from image_fetcher import main
|
9 |
from video import create_text_image
|
@@ -84,40 +85,24 @@ def generate_video():
|
|
84 |
lines.append('\n'.join(block_lines))
|
85 |
|
86 |
# Print or use lines as slides
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
if res.status_code == 200:
|
93 |
-
video_content = res.content
|
94 |
-
filename = f"clip{id}.mp4"
|
95 |
-
filepath = os.path.join(SAVE_DIR, filename)
|
96 |
-
|
97 |
-
with open(filepath, "wb") as f:
|
98 |
-
f.write(video_content)
|
99 |
-
|
100 |
-
return jsonify({
|
101 |
-
"status": "success",
|
102 |
-
"saved_to": filepath
|
103 |
-
})
|
104 |
-
else:
|
105 |
-
return jsonify({
|
106 |
-
"status": "error",
|
107 |
-
"code": res.status_code,
|
108 |
-
"message": res.text
|
109 |
-
})
|
110 |
-
|
111 |
-
except Exception as e:
|
112 |
-
return jsonify({"status": "failed", "error": str(e)})
|
113 |
-
|
114 |
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
except Exception as e:
|
122 |
traceback.print_exc()
|
123 |
return jsonify({"error": str(e)}), 500
|
|
|
4 |
import uuid
|
5 |
import glob
|
6 |
import os
|
7 |
+
import requests
|
8 |
import asyncio
|
9 |
from image_fetcher import main
|
10 |
from video import create_text_image
|
|
|
85 |
lines.append('\n'.join(block_lines))
|
86 |
|
87 |
# Print or use lines as slides
|
88 |
+
id=0
|
89 |
+
payload = {
|
90 |
+
"id": id,
|
91 |
+
"lines": lines
|
92 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
|
94 |
+
# Replace with your actual Space B URL
|
95 |
+
space_b_url = "https://sreepathi-ravikumar-subprocess1.hf.space/generate"
|
96 |
+
|
97 |
+
response = requests.post(space_b_url, json=payload)
|
98 |
+
|
99 |
+
if response.status_code == 200:
|
100 |
+
# Save received video file
|
101 |
+
with open(f"/app/data/video/clip{id}.mp4", "wb") as f:
|
102 |
+
f.write(response.content)
|
103 |
+
return f"/app/data/video/clip{id}.mp4"
|
104 |
+
else:
|
105 |
+
raise Exception(f"Error from Space B: {response.text}")
|
106 |
except Exception as e:
|
107 |
traceback.print_exc()
|
108 |
return jsonify({"error": str(e)}), 500
|