soiz commited on
Commit
305b2db
·
verified ·
1 Parent(s): 9d93a57

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -10
app.py CHANGED
@@ -1,24 +1,38 @@
1
  import os
2
- from flask import Flask, send_from_directory
3
 
4
  # リポジトリのクローンを行う
5
  def clone_repo():
6
- # 現在のディレクトリに`index.html`が存在しない場合のみクローンする
7
- if not os.path.exists('index.html'):
 
 
8
  print("Cloning the repository...")
9
  os.system("git clone https://github.com/ozh/cookieclicker.git .")
 
 
 
 
10
  else:
11
  print("Repository already cloned.")
12
 
13
  # クローンを実行
14
  clone_repo()
15
 
16
- app = Flask(__name__)
 
 
 
 
 
17
 
18
- # index.htmlをルートパスで表示
19
- @app.route('/')
20
- def index():
21
- return send_from_directory('.', 'index.html')
 
 
 
22
 
23
- if __name__ == '__main__':
24
- app.run(debug=True, port=7860)
 
1
  import os
2
+ import gradio as gr
3
 
4
  # リポジトリのクローンを行う
5
  def clone_repo():
6
+ # クローンしたかどうかを判定するファイル
7
+ clone_flag = "repo_cloned.flag"
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
 
19
  # クローンを実行
20
  clone_repo()
21
 
22
+ # Gradioアプリの作成
23
+ def display_index():
24
+ # index.htmlをHTMLとして読み込む
25
+ with open("index.html", "r") as file:
26
+ html_content = file.read()
27
+ return html_content
28
 
29
+ # Gradioインターフェースの設定
30
+ iface = gr.Interface(
31
+ fn=display_index,
32
+ inputs=None,
33
+ outputs="html",
34
+ live=True
35
+ )
36
 
37
+ if __name__ == "__main__":
38
+ iface.launch()