42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
# freeze.py
|
|
import os, shutil, warnings
|
|
from flask_frozen import Freezer, MimetypeMismatchWarning
|
|
from app import app
|
|
|
|
warnings.filterwarnings("ignore", category=MimetypeMismatchWarning)
|
|
|
|
# ─── set explicit build directory ───────────────────────────────
|
|
BUILD_DIR = "/var/www/bennysboard/build"
|
|
|
|
if os.path.exists(BUILD_DIR):
|
|
shutil.rmtree(BUILD_DIR)
|
|
|
|
app.config.update(
|
|
SERVER_NAME="bennysboard.local",
|
|
PREFERRED_URL_SCHEME="https",
|
|
FREEZER_DESTINATION=BUILD_DIR, # <── add this
|
|
FREEZER_IGNORE_MIMETYPE_WARNINGS=True,
|
|
FREEZER_REMOVE_EXTRA_FILES=True,
|
|
FREEZER_FLAT_URLS=True,
|
|
)
|
|
|
|
freezer = Freezer(app)
|
|
|
|
def manual_routes():
|
|
from flask import url_for
|
|
with app.app_context():
|
|
yield url_for("index")
|
|
yield url_for("login")
|
|
yield url_for("info_page")
|
|
|
|
def only_manual_routes(self):
|
|
for route in manual_routes():
|
|
yield type("Page", (), {"url": route})()
|
|
|
|
freezer.freeze_yield = only_manual_routes.__get__(freezer, Freezer)
|
|
|
|
if __name__ == "__main__":
|
|
freezer.freeze()
|
|
print(f"\n✅ Freeze complete — static site built in {BUILD_DIR}\n")
|
|
|