a654852675556e1f900bd85e7f1a77a49eb3a623 — Jochen Kupperschmidt 1 year, 9 months ago 1b8d711
Do not serve data files from app server in development mode

Instead, configure a local web server (like nginx) for development. This
is a lot closer to a production setup anyway.

The goal of this change is to pave the way for the removal of
site-specific configuration files, and for the introduction of
multi-site capabilities of a single application instance.
1 files changed, 0 insertions(+), 27 deletions(-)

M app.py
M app.py => app.py +0 -27
@@ 6,10 6,6 @@ application instance
:License: Modified BSD, see LICENSE for details.

from pathlib import Path

from werkzeug.wsgi import SharedDataMiddleware

from byceps.application import create_app, init_app
from byceps import config
from byceps.database import db

@@ 34,30 30,7 @@ app = create_app(config_filename)

def _generate_static_files_exports():
    """Yield static files exports."""
    # global, brand-specific, and party-specific files
    for url_path, config_key in [
        ('/global', 'PATH_GLOBAL'),
        ('/brand', 'PATH_BRAND'),
        ('/party', 'PATH_PARTY'),
        path = app.config.get(config_key)
        if path:
            yield url_path, str(path)

    # site-specific files
    if config.get_site_mode(app).is_public():
        site_id = config.get_current_site_id(app)
        site_files_path = Path('sites') / site_id / 'static'
        yield '/site', str(site_files_path)

if app.env == 'development':
    # Share static files.
    exports = dict(_generate_static_files_exports())
    app.wsgi_app = SharedDataMiddleware(app.wsgi_app, exports)

    if app.debug:
        # Enable debug toolbar.
        from flask_debugtoolbar import DebugToolbarExtension