Spanicin commited on
Commit
6d6c7a1
·
verified ·
1 Parent(s): d2691f9

Update app_parallel.py

Browse files
Files changed (1) hide show
  1. app_parallel.py +12 -2
app_parallel.py CHANGED
@@ -71,7 +71,9 @@ class AnimationConfig:
71
 
72
 
73
  app = Flask(__name__)
74
- # CORS(app)
 
 
75
 
76
  TEMP_DIR = None
77
  start_time = None
@@ -318,9 +320,17 @@ def generate_chunks(audio_chunks, preprocessed_data, args, m3u8_path, audio_dura
318
  yield f"Task for chunk {idx} failed: {e}\n"
319
  finally:
320
  if TEMP_DIR:
 
321
  custom_cleanup(TEMP_DIR.name)
322
 
323
-
 
 
 
 
 
 
 
324
  @app.route("/run", methods=['POST'])
325
  def parallel_processing():
326
  global start_time
 
71
 
72
 
73
  app = Flask(__name__)
74
+
75
+ from flask_cors import CORS
76
+ CORS(app,origins=["*"])
77
 
78
  TEMP_DIR = None
79
  start_time = None
 
320
  yield f"Task for chunk {idx} failed: {e}\n"
321
  finally:
322
  if TEMP_DIR:
323
+ close_m3u8(m3u8_path)
324
  custom_cleanup(TEMP_DIR.name)
325
 
326
+ def close_m3u8(m3u8_path: str):
327
+ try:
328
+ with open(m3u8_path, 'a') as m3u8_file:
329
+ m3u8_file.write('#EXT-X-ENDLIST\n')
330
+ print(f"Closed m3u8 file with end tag: {m3u8_path}")
331
+ except Exception as e:
332
+ print(f"Error closing m3u8 file: {e}")
333
+
334
  @app.route("/run", methods=['POST'])
335
  def parallel_processing():
336
  global start_time