soiz commited on
Commit
489bf3c
·
verified ·
1 Parent(s): b22d44e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -0
app.py CHANGED
@@ -19,6 +19,12 @@ def clone_repo():
19
  else:
20
  # index.htmlをカレントディレクトリに移動
21
  shutil.move(os.path.join(temp_dir, 'index.html'), '.')
 
 
 
 
 
 
22
 
23
  # クローンを実行
24
  clone_repo()
@@ -34,6 +40,11 @@ def index():
34
  return abort(404, description="index.html not found.")
35
  return send_from_directory('.', 'index.html')
36
 
 
 
 
 
 
37
  if __name__ == '__main__':
38
  # port 7860でFlaskアプリを起動
39
  app.run(host='0.0.0.0', port=7860)
 
19
  else:
20
  # index.htmlをカレントディレクトリに移動
21
  shutil.move(os.path.join(temp_dir, 'index.html'), '.')
22
+ # 静的ファイルをstaticディレクトリに移動
23
+ if not os.path.exists('static'):
24
+ os.mkdir('static')
25
+ for item in os.listdir(temp_dir):
26
+ if item != 'index.html':
27
+ shutil.move(os.path.join(temp_dir, item), os.path.join('static', item))
28
 
29
  # クローンを実行
30
  clone_repo()
 
40
  return abort(404, description="index.html not found.")
41
  return send_from_directory('.', 'index.html')
42
 
43
+ # 静的ファイルを提供するためのルート
44
+ @app.route('/<path:filename>')
45
+ def static_files(filename):
46
+ return send_from_directory('static', filename)
47
+
48
  if __name__ == '__main__':
49
  # port 7860でFlaskアプリを起動
50
  app.run(host='0.0.0.0', port=7860)