GPTfree api commited on
Commit
38df333
·
verified ·
1 Parent(s): 9b40771

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -12,6 +12,8 @@ def change_permissions(directory):
12
  print(f"Permissions for {directory} changed to 775.")
13
  except subprocess.CalledProcessError as e:
14
  print(f"Error changing permissions for {directory}: {e}")
 
 
15
 
16
  @app.route('/download', methods=['GET'])
17
  def download_video():
@@ -26,7 +28,8 @@ def download_video():
26
  os.makedirs(output_path, exist_ok=True) # ダウンロード先ディレクトリが存在しない場合、作成する
27
 
28
  # `downloads`ディレクトリの権限を775に変更
29
- change_permissions(output_path)
 
30
 
31
  # 出力ファイル名テンプレート
32
  output_file = os.path.join(output_path, '%(title)s.%(ext)s')
 
12
  print(f"Permissions for {directory} changed to 775.")
13
  except subprocess.CalledProcessError as e:
14
  print(f"Error changing permissions for {directory}: {e}")
15
+ return False
16
+ return True
17
 
18
  @app.route('/download', methods=['GET'])
19
  def download_video():
 
28
  os.makedirs(output_path, exist_ok=True) # ダウンロード先ディレクトリが存在しない場合、作成する
29
 
30
  # `downloads`ディレクトリの権限を775に変更
31
+ if not change_permissions(output_path):
32
+ return jsonify({"error": "Failed to change directory permissions"}), 500
33
 
34
  # 出力ファイル名テンプレート
35
  output_file = os.path.join(output_path, '%(title)s.%(ext)s')