Update app.py
Browse files
app.py
CHANGED
|
@@ -10,6 +10,9 @@ from video import create_text_image
|
|
| 10 |
from video2 import video_com
|
| 11 |
|
| 12 |
app = Flask(__name__)
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
@app.route("/")
|
| 15 |
def home():
|
|
@@ -81,13 +84,32 @@ def generate_video():
|
|
| 81 |
lines.append('\n'.join(block_lines))
|
| 82 |
|
| 83 |
# Print or use lines as slides
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
-
image_olst=[]
|
| 86 |
-
for id in range(len(lines)):
|
| 87 |
-
create_text_image(lines[id],id,image_olst)
|
| 88 |
-
image_files = sorted(glob.glob(os.path.join(image_folder, "*.png")))
|
| 89 |
-
if not image_files:
|
| 90 |
-
raise ValueError("No images found in folder!")
|
| 91 |
|
| 92 |
video_path = video_com(lines)
|
| 93 |
for img in image_files:
|
|
|
|
| 10 |
from video2 import video_com
|
| 11 |
|
| 12 |
app = Flask(__name__)
|
| 13 |
+
SUBSPACE_URL = "https://sreepathi-ravikumar-subprocess1.hf.space"
|
| 14 |
+
SAVE_DIR = "/app/data/video/"
|
| 15 |
+
os.makedirs(SAVE_DIR, exist_ok=True)
|
| 16 |
|
| 17 |
@app.route("/")
|
| 18 |
def home():
|
|
|
|
| 84 |
lines.append('\n'.join(block_lines))
|
| 85 |
|
| 86 |
# Print or use lines as slides
|
| 87 |
+
id=0
|
| 88 |
+
try:
|
| 89 |
+
# Send list + int to subspace
|
| 90 |
+
res = requests.post(SUBSPACE_URL, json={"lines": lines, "id": id})
|
| 91 |
+
if res.status_code == 200:
|
| 92 |
+
video_content = res.content
|
| 93 |
+
filename = f"video_{datetime.now().strftime('%Y%m%d_%H%M%S')}.mp4"
|
| 94 |
+
filepath = os.path.join(SAVE_DIR, filename)
|
| 95 |
+
|
| 96 |
+
with open(filepath, "wb") as f:
|
| 97 |
+
f.write(video_content)
|
| 98 |
+
|
| 99 |
+
return jsonify({
|
| 100 |
+
"status": "success",
|
| 101 |
+
"saved_to": filepath
|
| 102 |
+
})
|
| 103 |
+
else:
|
| 104 |
+
return jsonify({
|
| 105 |
+
"status": "error",
|
| 106 |
+
"code": res.status_code,
|
| 107 |
+
"message": res.text
|
| 108 |
+
})
|
| 109 |
+
|
| 110 |
+
except Exception as e:
|
| 111 |
+
return jsonify({"status": "failed", "error": str(e)})
|
| 112 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
|
| 114 |
video_path = video_com(lines)
|
| 115 |
for img in image_files:
|