API === Creating Factories ------------------ .. module:: broadway .. autofunction:: factory Factory Objects --------------- .. module:: broadway.app .. autoclass:: Factory :members: :show-inheritance: Config Schema ------------- A config schema representing the default configuration values for flask can be found at :code:`broadway.config.SCHEMA`, this is added by default to any factory created using the :meth:`~broadway.factory()` method. Available options are specified in :ref:`config_schema`. Built-in Extensions ------------------- Broadway ships with a handful of built-in extensions. You load built-in extensions like others using :meth:`~broadway.app.Factory.add_extensions`. Please see :doc:`extensions` for more information. Error Handling ~~~~~~~~~~~~~~ .. currentmodule: broadway.error A default error handler that renders a template when a :exc:`~werkzeug.exceptions.HTTPException` is raised. Example ******* .. code-block:: python factory = broadway.factory() factory.add_extensions( 'broadway.errors' ) Now any HTTP exception will try and render a template from :file:`templates/errors/` named after the error code. .. code-block:: html 410 Gone

410 Gone

You can then either raise a :exc:`~werkzeug.exceptions.HTTPException` subclass or use :meth:`~flask.abort`. Instead of the default response the template will be now rendered. .. code-block:: python from flask import abort from werkzeug.exceptions import Gone @blueprint.route('/') def my_view() abort(410) @blueprint.route('/other') def my_other_view() raise Gone() Whitenoise ~~~~~~~~~~ .. currentmodule: broadway.whitenoise A broadway extension to setup WhiteNoise to serve static assets. WhiteNoise is a production ready WSGI middleware for serving static assets. Once enabled it will serve assets from flasks static folder. Example ******* .. code-block:: python factory = broadway.factory() factory.add_extensions( 'broadway.whitenoise' ) See the :ref:`whitenoise_config` config schema for available options.