Frozen-Flask

raw JSON →
1.0.2 verified Mon Apr 27 auth: no python

Freezes a Flask application into a set of static files. Version 1.0.2 is current (released 2024) and supports Python >=3.8 with Flask 2 and 3. The library follows a stable release cadence.

pip install frozen-flask
error ModuleNotFoundError: No module named 'flask_frozen'
cause Installed frozen-flask but imported with wrong name.
fix
Use 'from flask_frozen import Freezer'. Package name is frozen-flask, module is flask_frozen.
error flask_frozen.FlaskFrozenError: No URLs found to freeze. Build will be empty.
cause No routes discovered because the app doesn't expose any URLs that can be reached via GET requests.
fix
Ensure you have at least one route decorated with @app.route and that the app is properly configured.
error OSError: [Errno 2] No such file or directory: 'build/index.html'
cause The freezer tried to write a file but the build directory doesn't exist.
fix
Set FREEZER_DESTINATION_DIR to an existing directory or let the freezer create it (default is 'build').
breaking Version 1.0.0 dropped support for Python 2 and PyPy. Flask 2 and 3 only.
fix Use Python >=3.8 and Flask >=2.
deprecated The `FREEZER_DESTINATION` config option is deprecated in favor of `FREEZER_DESTINATION_DIR` in some docs; check your version.
fix Use `FREEZER_DESTINATION_DIR` if using Frozen-Flask 1.x.
gotcha Static files need to be included explicitly via the app's static folder or via `url_for('static', ...)` in your templates. Frozen-Flask only processes routes it discovers during crawling.
fix Ensure all static assets are linked from pages that are discoverable by the freezer.
gotcha The freezer does not follow external links; if your app links to other sites, those won't be frozen.
fix Use `@freezer.register_generator` to explicitly add URLs that are not discovered by crawling.

Basic usage: create a Flask app, attach Freezer, and call freeze().

from flask import Flask
from flask_frozen import Freezer

app = Flask(__name__)

@app.route('/')
def index():
    return 'Hello, world!'

freezer = Freezer(app)

if __name__ == '__main__':
    freezer.freeze()