soiz commited on
Commit
1a28ce3
·
verified ·
1 Parent(s): 7847b1d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -1,5 +1,5 @@
1
  import os
2
- from flask import Flask, send_from_directory
3
 
4
  # リポジトリのクローンを行う
5
  def clone_repo():
@@ -8,11 +8,13 @@ def clone_repo():
8
 
9
  if not os.path.exists(clone_flag):
10
  print("Cloning the repository...")
11
- os.system("git clone https://github.com/ozh/cookieclicker.git .")
12
-
13
- # クローン完了後にフラグファイルを作成
14
- with open(clone_flag, 'w') as f:
15
- f.write("Repository has been cloned.")
 
 
16
  else:
17
  print("Repository already cloned.")
18
 
@@ -25,6 +27,9 @@ app = Flask(__name__)
25
  # ルートでindex.htmlを表示
26
  @app.route('/')
27
  def index():
 
 
 
28
  return send_from_directory('.', 'index.html')
29
 
30
  if __name__ == '__main__':
 
1
  import os
2
+ from flask import Flask, send_from_directory, abort
3
 
4
  # リポジトリのクローンを行う
5
  def clone_repo():
 
8
 
9
  if not os.path.exists(clone_flag):
10
  print("Cloning the repository...")
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
  print("Repository already cloned.")
20
 
 
27
  # ルートでindex.htmlを表示
28
  @app.route('/')
29
  def index():
30
+ # index.htmlが存在しない場合は404エラー
31
+ if not os.path.exists("index.html"):
32
+ return abort(404, description="index.html not found.")
33
  return send_from_directory('.', 'index.html')
34
 
35
  if __name__ == '__main__':