Update app.py
Browse files
app.py
CHANGED
@@ -1,22 +1,24 @@
|
|
1 |
import os
|
|
|
2 |
from flask import Flask, send_from_directory, abort
|
3 |
|
|
|
|
|
|
|
4 |
# リポジトリのクローンを行う
|
5 |
def clone_repo():
|
6 |
-
#
|
7 |
-
|
|
|
|
|
|
|
|
|
8 |
|
9 |
-
if
|
10 |
-
print("
|
11 |
-
result = os.system("git clone https://github.com/ozh/cookieclicker.git .")
|
12 |
-
if result != 0:
|
13 |
-
print("Error: Failed to clone the repository.")
|
14 |
-
else:
|
15 |
-
# クローン完了後にフラグファイルを作成
|
16 |
-
with open(clone_flag, 'w') as f:
|
17 |
-
f.write("Repository has been cloned.")
|
18 |
else:
|
19 |
-
|
|
|
20 |
|
21 |
# クローンを実行
|
22 |
clone_repo()
|
|
|
1 |
import os
|
2 |
+
import shutil
|
3 |
from flask import Flask, send_from_directory, abort
|
4 |
|
5 |
+
# リポジトリをクローンするディレクトリ
|
6 |
+
temp_dir = "/tmp/cookieclicker_repo"
|
7 |
+
|
8 |
# リポジトリのクローンを行う
|
9 |
def clone_repo():
|
10 |
+
# 一時ディレクトリが存在する場合は削除
|
11 |
+
if os.path.exists(temp_dir):
|
12 |
+
shutil.rmtree(temp_dir)
|
13 |
+
|
14 |
+
print("Cloning the repository...")
|
15 |
+
result = os.system(f"git clone https://github.com/ozh/cookieclicker.git {temp_dir}")
|
16 |
|
17 |
+
if result != 0:
|
18 |
+
print("Error: Failed to clone the repository.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
else:
|
20 |
+
# index.htmlをカレントディレクトリに移動
|
21 |
+
shutil.move(os.path.join(temp_dir, 'index.html'), '.')
|
22 |
|
23 |
# クローンを実行
|
24 |
clone_repo()
|