Spaces:
Sleeping
Sleeping
$P@D$3RV£R commited on
Commit ·
6b151fa
1
Parent(s): 9356443
Add safety check for current_folder_set before template rendering
Browse files
app.py
CHANGED
|
@@ -454,7 +454,25 @@ def tagger():
|
|
| 454 |
hf_all_time_visits = None
|
| 455 |
|
| 456 |
print(f"DEBUG: About to render template. current_folder_set: {current_folder_set is not None}, current_images: {len(current_images)}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 457 |
try:
|
|
|
|
| 458 |
result = render_template(
|
| 459 |
'tagger.html',
|
| 460 |
has_prev_folder=has_prev_folder,
|
|
@@ -463,7 +481,7 @@ def tagger():
|
|
| 463 |
has_next_set=has_next_set,
|
| 464 |
directory=directory,
|
| 465 |
current_folder_set=current_folder_set,
|
| 466 |
-
current_folder=
|
| 467 |
current_images=current_images,
|
| 468 |
labels=labels,
|
| 469 |
head=app.config["HEAD"] + 1,
|
|
|
|
| 454 |
hf_all_time_visits = None
|
| 455 |
|
| 456 |
print(f"DEBUG: About to render template. current_folder_set: {current_folder_set is not None}, current_images: {len(current_images)}")
|
| 457 |
+
|
| 458 |
+
# Ensure we have all required variables
|
| 459 |
+
if current_folder_set is None:
|
| 460 |
+
return f"""
|
| 461 |
+
<!DOCTYPE html>
|
| 462 |
+
<html>
|
| 463 |
+
<head>
|
| 464 |
+
<title>Data Error</title>
|
| 465 |
+
<meta charset="UTF-8">
|
| 466 |
+
</head>
|
| 467 |
+
<body>
|
| 468 |
+
<h1>Data Error</h1>
|
| 469 |
+
<p>Unable to load folder data. Please check the Space logs.</p>
|
| 470 |
+
</body>
|
| 471 |
+
</html>
|
| 472 |
+
""", 500
|
| 473 |
+
|
| 474 |
try:
|
| 475 |
+
current_folder_name = current_folder_set.get('folder', 'Unknown') if isinstance(current_folder_set, dict) else 'Unknown'
|
| 476 |
result = render_template(
|
| 477 |
'tagger.html',
|
| 478 |
has_prev_folder=has_prev_folder,
|
|
|
|
| 481 |
has_next_set=has_next_set,
|
| 482 |
directory=directory,
|
| 483 |
current_folder_set=current_folder_set,
|
| 484 |
+
current_folder=current_folder_name,
|
| 485 |
current_images=current_images,
|
| 486 |
labels=labels,
|
| 487 |
head=app.config["HEAD"] + 1,
|