Update app.py
Browse files
app.py
CHANGED
|
@@ -13,7 +13,7 @@ def clone_and_setup_repo():
|
|
| 13 |
shutil.rmtree(temp_dir)
|
| 14 |
|
| 15 |
print("Cloning the repository...")
|
| 16 |
-
result = os.system(f"git clone https://github.com/
|
| 17 |
|
| 18 |
if result != 0:
|
| 19 |
print("Error: Failed to clone the repository.")
|
|
@@ -22,23 +22,24 @@ def clone_and_setup_repo():
|
|
| 22 |
# クローンしたディレクトリに移動してセットアップ
|
| 23 |
os.chdir(temp_dir)
|
| 24 |
os.system("npm i")
|
| 25 |
-
os.system("cp
|
|
|
|
| 26 |
os.system("npm run build")
|
| 27 |
-
os.system("
|
| 28 |
|
| 29 |
# index.htmlをカレントディレクトリに移動
|
| 30 |
-
index_html_path = os.path.join(temp_dir, '
|
| 31 |
if os.path.exists(index_html_path):
|
| 32 |
-
if os.path.exists('
|
| 33 |
-
os.remove('
|
| 34 |
shutil.move(index_html_path, '.')
|
| 35 |
|
| 36 |
# 静的ファイルをstaticディレクトリに移動
|
| 37 |
-
if not os.path.exists('static'):
|
| 38 |
-
os.mkdir('static')
|
| 39 |
-
for item in os.listdir(temp_dir):
|
| 40 |
-
if item != 'index.html':
|
| 41 |
-
shutil.move(os.path.join(temp_dir, item), os.path.join('static', item))
|
| 42 |
|
| 43 |
# クローンとセットアップを実行
|
| 44 |
clone_and_setup_repo()
|
|
@@ -50,12 +51,14 @@ app = Flask(__name__)
|
|
| 50 |
@app.route('/')
|
| 51 |
def index():
|
| 52 |
# index.htmlが存在しない場合は404エラー
|
| 53 |
-
if not os.path.exists("
|
|
|
|
| 54 |
return abort(404, description="index.html not found.")
|
| 55 |
|
| 56 |
# index.htmlの内容を読み込む
|
| 57 |
-
with open("
|
| 58 |
index_html_content = file.read()
|
|
|
|
| 59 |
|
| 60 |
return render_template_string(index_html_content)
|
| 61 |
|
|
@@ -64,6 +67,14 @@ def index():
|
|
| 64 |
def static_files(filename):
|
| 65 |
return send_from_directory('static', filename)
|
| 66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
if __name__ == '__main__':
|
| 68 |
# port 7860でFlaskアプリを起動
|
| 69 |
app.run(host='0.0.0.0', port=7860)
|
|
|
|
| 13 |
shutil.rmtree(temp_dir)
|
| 14 |
|
| 15 |
print("Cloning the repository...")
|
| 16 |
+
result = os.system(f"git clone https://github.com/titaniumnetwork-dev/incognito.git --recursive {temp_dir}")
|
| 17 |
|
| 18 |
if result != 0:
|
| 19 |
print("Error: Failed to clone the repository.")
|
|
|
|
| 22 |
# クローンしたディレクトリに移動してセットアップ
|
| 23 |
os.chdir(temp_dir)
|
| 24 |
os.system("npm i")
|
| 25 |
+
os.system("cp .env.example .env")
|
| 26 |
+
os.system("nano .env")
|
| 27 |
os.system("npm run build")
|
| 28 |
+
os.system("npm start")
|
| 29 |
|
| 30 |
# index.htmlをカレントディレクトリに移動
|
| 31 |
+
index_html_path = os.path.join(temp_dir, 'index.html')
|
| 32 |
if os.path.exists(index_html_path):
|
| 33 |
+
if os.path.exists('index.html'):
|
| 34 |
+
os.remove('index.html')
|
| 35 |
shutil.move(index_html_path, '.')
|
| 36 |
|
| 37 |
# 静的ファイルをstaticディレクトリに移動
|
| 38 |
+
# if not os.path.exists('static'):
|
| 39 |
+
# os.mkdir('static')
|
| 40 |
+
# for item in os.listdir(temp_dir):
|
| 41 |
+
# if item != 'index.html':
|
| 42 |
+
# shutil.move(os.path.join(temp_dir, item), os.path.join('static', item))
|
| 43 |
|
| 44 |
# クローンとセットアップを実行
|
| 45 |
clone_and_setup_repo()
|
|
|
|
| 51 |
@app.route('/')
|
| 52 |
def index():
|
| 53 |
# index.htmlが存在しない場合は404エラー
|
| 54 |
+
if not os.path.exists("index.html"):
|
| 55 |
+
print("index 404")
|
| 56 |
return abort(404, description="index.html not found.")
|
| 57 |
|
| 58 |
# index.htmlの内容を読み込む
|
| 59 |
+
with open("index.html", "r") as file:
|
| 60 |
index_html_content = file.read()
|
| 61 |
+
print("index.htmlok")
|
| 62 |
|
| 63 |
return render_template_string(index_html_content)
|
| 64 |
|
|
|
|
| 67 |
def static_files(filename):
|
| 68 |
return send_from_directory('static', filename)
|
| 69 |
|
| 70 |
+
# main.jsの存在を確認するエンドポイント
|
| 71 |
+
@app.route('/check_main_js')
|
| 72 |
+
def check_main_js():
|
| 73 |
+
if os.path.exists('static/main.js'):
|
| 74 |
+
return "main.js exists."
|
| 75 |
+
else:
|
| 76 |
+
return "main.js does not exist."
|
| 77 |
+
|
| 78 |
if __name__ == '__main__':
|
| 79 |
# port 7860でFlaskアプリを起動
|
| 80 |
app.run(host='0.0.0.0', port=7860)
|