soiz1 commited on
Commit
260a17e
·
verified ·
1 Parent(s): eb5bcea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -12
app.py CHANGED
@@ -31,26 +31,29 @@ def index():
31
 
32
  @app.route("/<path:filepath>")
33
  def serve_any(filepath):
34
- app.logger.info(f"Request for file: {filepath}")
35
 
36
- # static フォルダ内のファイルをチェック
37
  static_path = os.path.join(app.static_folder, filepath)
38
- app.logger.info(f"Checking static path: {static_path}")
39
- if os.path.isfile(static_path):
40
- app.logger.info(f"Serving from static: {filepath}")
 
41
  return send_from_directory(app.static_folder, filepath)
42
-
43
- # REPO_DIR内のファイルをチェック
44
  full_path = os.path.join(REPO_DIR, filepath)
45
- app.logger.info(f"Checking repo path: {full_path}")
46
- if os.path.isfile(full_path):
 
47
  directory, filename = os.path.split(full_path)
48
- app.logger.info(f"Serving from repo: directory={directory}, filename={filename}")
49
  return send_from_directory(directory, filename)
50
-
51
- app.logger.warning(f"File not found: {filepath}")
52
  abort(404)
53
 
 
54
  # 読み取り専用ファイルを削除できるようにする
55
  def remove_readonly(func, path, excinfo):
56
  os.chmod(path, stat.S_IWRITE)
 
31
 
32
  @app.route("/<path:filepath>")
33
  def serve_any(filepath):
34
+ app.logger.debug(f"📥 リクエストされたパス: {filepath!r}")
35
 
36
+ # 1) static フォルダ
37
  static_path = os.path.join(app.static_folder, filepath)
38
+ exists_static = os.path.isfile(static_path)
39
+ app.logger.debug(f"→ static をチェック: {static_path!r} 存在? {exists_static}")
40
+ if exists_static:
41
+ app.logger.info(f"✅ static から返却: {filepath}")
42
  return send_from_directory(app.static_folder, filepath)
43
+
44
+ # 2) リポジトリ直下
45
  full_path = os.path.join(REPO_DIR, filepath)
46
+ exists_repo = os.path.isfile(full_path)
47
+ app.logger.debug(f"→ repo をチェック: {full_path!r} 存在? {exists_repo}")
48
+ if exists_repo:
49
  directory, filename = os.path.split(full_path)
50
+ app.logger.info(f" repo から返却: ディレクトリ={directory!r}, ファイル名={filename!r}")
51
  return send_from_directory(directory, filename)
52
+
53
+ app.logger.warning(f" ファイルが見つからない: {filepath!r}")
54
  abort(404)
55
 
56
+
57
  # 読み取り専用ファイルを削除できるようにする
58
  def remove_readonly(func, path, excinfo):
59
  os.chmod(path, stat.S_IWRITE)