Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -31,26 +31,29 @@ def index():
|
|
31 |
|
32 |
@app.route("/<path:filepath>")
|
33 |
def serve_any(filepath):
|
34 |
-
app.logger.
|
35 |
|
36 |
-
# static
|
37 |
static_path = os.path.join(app.static_folder, filepath)
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
41 |
return send_from_directory(app.static_folder, filepath)
|
42 |
-
|
43 |
-
#
|
44 |
full_path = os.path.join(REPO_DIR, filepath)
|
45 |
-
|
46 |
-
|
|
|
47 |
directory, filename = os.path.split(full_path)
|
48 |
-
app.logger.info(f"
|
49 |
return send_from_directory(directory, filename)
|
50 |
-
|
51 |
-
app.logger.warning(f"
|
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)
|