App configuration

class coaster.app.SandboxedFlask(import_name, static_path=None, static_url_path=None, static_folder='static', template_folder='templates', instance_path=None, instance_relative_config=False, root_path=None)[source]

Flask with a sandboxed Jinja2 environment, for when your app’s templates need sandboxing. Useful when your app works with externally provided templates:

from coaster.app import SandboxedFlask
app = SandboxedFlask(__name__)
create_jinja_environment()[source]

Creates the Jinja2 environment based on jinja_options and select_jinja_autoescape(). Since 0.7 this also adds the Jinja2 globals and filters after initialization. Override this function to customize the behavior.

coaster.app.init_app(app, env=None)[source]

Configure an app depending on the environment. Loads settings from a file named settings.py in the instance folder, followed by additional settings from one of development.py, production.py or testing.py. Typical usage:

from flask import Flask
import coaster.app

app = Flask(__name__, instance_relative_config=True)
coaster.app.init_app(app)  # Guess environment automatically

init_app() also configures logging by calling coaster.logger.init_app().

Parameters:
  • app – App to be configured
  • env – Environment to configure for ('development', 'production' or 'testing'). If not specified, the FLASK_ENV environment variable is consulted. Defaults to 'development'.