Skip to content

Commit a3ab04a

Browse files
authored
Update freeze.py
1 parent 4546e4c commit a3ab04a

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

freeze.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
# --- Configuration for GitHub Pages ---
99
# Sets the base URL. CRITICAL for links/CSS/JS on GitHub Pages.
10-
# Must match your repository name structure.
10+
# MUST match your repository name path.
1111
print("Setting FREEZER_BASE_URL to '/'")
1212
app.config['FREEZER_BASE_URL'] = '/'
1313

@@ -16,49 +16,41 @@
1616
# Keep .nojekyll file if generated by GitHub Actions
1717
app.config['FREEZER_REMOVE_EXTRA_FILES'] = False
1818

19+
# *** ADD THIS LINE TO FIX THE REDIRECT ISSUE ***
20+
app.config['FREEZER_FOLLOW_REDIRECTS'] = True # Tell Frozen-Flask to follow 3xx redirects
21+
1922
# --- Handling Dynamic URLs (IMPORTANT LIMITATION) ---
2023
# Static site generation CANNOT dynamically create pages for every possible
2124
# block, transaction, or address. We MUST provide examples/placeholders
2225
# for Frozen-Flask to generate the *structure* of these pages.
23-
# The actual *data* on these generated pages will only reflect
24-
# what Flask renders for these specific placeholder values during the build.
25-
# Features requiring real-time data or searching arbitrary hashes won't work fully.
26-
2726
freezer = Freezer(app)
2827

2928
@freezer.register_generator
3029
def transaction_urls():
3130
print("Generating static structure for /tx/<hash> using placeholder.")
32-
# Provide one placeholder hash to generate the template structure
3331
yield {'tx_hash': 'placeholder_tx_hash'}
3432

3533
@freezer.register_generator
3634
def block_urls():
3735
print("Generating static structure for /block/<hash> using placeholder.")
38-
# Provide one placeholder hash/number
3936
yield {'block_hash': 'placeholder_block_hash_or_number'}
4037

4138
@freezer.register_generator
4239
def address_urls():
4340
print("Generating static structure for /address/<addr> using placeholder.")
44-
# Provide one placeholder address
4541
yield {'address': 'placeholder_address'}
4642

47-
# You might have other dynamic routes - add generators for them too!
48-
4943
# Main execution block for freezing
5044
if __name__ == '__main__':
5145
print(f"Starting static site generation for pyExplorer...")
5246
print(f"Base URL: {app.config.get('FREEZER_BASE_URL', 'Not Set')}")
5347
print(f"Output directory: {app.config.get('FREEZER_DESTINATION', 'build')}")
48+
print(f"Follow Redirects: {app.config.get('FREEZER_FOLLOW_REDIRECTS', False)}")
5449

5550
try:
56-
# This crawls your Flask app (using defined routes and generators)
57-
# and saves the output as static files.
5851
freezer.freeze()
5952
print(f"Static site generated successfully in '{app.config['FREEZER_DESTINATION']}'.")
6053
print("NOTE: Only placeholder pages were generated for dynamic routes (/tx, /block, /address).")
61-
print("Full dynamic explorer functionality requires a live backend or client-side fetching.")
6254
except Exception as e:
6355
print(f"\nERROR during freezing process: {e}\n", file=sys.stderr)
6456
if isinstance(e, ValueError) and 'URL generator' in str(e):

0 commit comments

Comments
 (0)