or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

configuration.mdcore-freezing.mdindex.mdurl-generation.mdutilities.md
tile.json

tessl/pypi-frozen-flask

Freezes a Flask application into a set of static files.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/frozen-flask@1.0.x

To install, run

npx @tessl/cli install tessl/pypi-frozen-flask@1.0.0

index.mddocs/

Frozen-Flask

Frozen-Flask transforms Flask web applications into static websites by generating static HTML files from all accessible URLs. It provides a comprehensive freezing system with configurable URL generators, automatic static file handling, and support for custom routing patterns.

Package Information

  • Package Name: Frozen-Flask
  • Package Type: pypi
  • Language: Python
  • Installation: pip install Frozen-Flask
  • Dependencies: Flask >=2.0.0

Core Imports

from flask_frozen import Freezer

Complete import for all public functionality:

from flask_frozen import Freezer, walk_directory, relative_url_for

Basic Usage

from flask import Flask
from flask_frozen import Freezer

# Create Flask app
app = Flask(__name__)

@app.route('/')
def index():
    return '<h1>Hello World!</h1>'

@app.route('/page/<name>/')
def page(name):
    return f'<h1>Page: {name}</h1>'

# Initialize freezer
freezer = Freezer(app)

# Register URL generator for dynamic routes
@freezer.register_generator
def page_urls():
    yield 'page', {'name': 'about'}
    yield 'page', {'name': 'contact'}

# Freeze the application to static files
if __name__ == '__main__':
    freezer.freeze()  # Generates static files in 'build/' directory

Architecture

Frozen-Flask operates through a flexible URL generation system that discovers and processes all URLs in a Flask application:

  • Freezer: Core class that orchestrates the freezing process, managing URL discovery, file generation, and build output
  • URL Generators: Functions that yield URLs or endpoint patterns to be processed during freezing
  • Build Process: Systematic generation of static files from Flask responses, with support for incremental builds and smart file comparison
  • Configuration System: Extensive configuration options for customizing build behavior, file handling, and URL processing

The library automatically handles static files, applies URL generators for dynamic routes, and provides hooks for custom URL generation patterns, making it suitable for converting any Flask application into a deployable static website.

Capabilities

Core Freezing Operations

Primary functionality for converting Flask applications to static sites, including the main Freezer class, build process control, and URL discovery mechanisms.

class Freezer:
    def __init__(self, app=None, with_static_files=True, 
                 with_no_argument_rules=True, log_url_for=True): ...
    def init_app(self, app): ...
    def freeze(self): ...
    def freeze_yield(self): ...
    def all_urls(self): ...

Core Freezing

URL Generation and Registration

Advanced URL generation system for handling dynamic routes, custom URL patterns, and endpoint discovery.

def register_generator(self, function): ...
def static_files_urls(self): ...
def no_argument_rules_urls(self): ...

URL Generation

Configuration and Customization

Comprehensive configuration system for controlling build behavior, file handling, error processing, and output customization.

# Configuration options set automatically on app.config
FREEZER_DESTINATION: str
FREEZER_BASE_URL: str
FREEZER_RELATIVE_URLS: bool
FREEZER_REMOVE_EXTRA_FILES: bool

Configuration

Utility Functions

Helper functions for directory operations, relative URL generation, and file system utilities.

def walk_directory(root, ignore=()): ...
def relative_url_for(endpoint, **values): ...

Utilities

Error Handling

Frozen-Flask provides a comprehensive warning system for common issues:

class FrozenFlaskWarning(Warning): ...
class MissingURLGeneratorWarning(FrozenFlaskWarning): ...
class MimetypeMismatchWarning(FrozenFlaskWarning): ...
class NotFoundWarning(FrozenFlaskWarning): ...
class RedirectWarning(FrozenFlaskWarning): ...

These warnings help identify missing URL generators, MIME type conflicts, 404 responses, and redirect handling issues during the build process.