os.environ['HMAC_KEY'] = base64.b64encode(b'').decode()

# Stop the app from reloading/initing twice
print("reloading", os.environ.get('WERKZEUG_RUN_MAIN'), os.environ)
if os.environ.get('FLASK_DEBUG') is not None and os.environ.get(
        'WERKZEUG_RUN_MAIN') != 'true':
    raise ValueError('Prevented reload')

# live building of scss
from sassutils.wsgi import SassMiddleware, Manifest
app.wsgi_app = SassMiddleware(
    app.wsgi_app, {
        'overtrack_web':
        Manifest(
            '../static/scss',
            '../static/css',
            '/static/css',
            strip_extension=True,
        )
    })

# Force js to be unminified
orig_url_for = flask.url_for


def url_for(endpoint, **values):
    if endpoint == 'static' and 'filename' in values and values[
            'filename'].endswith('.min.js'):
        values['filename'] = values['filename'][:-len('.min.js')] + '.js'
    return orig_url_for(endpoint, **values)

Ejemplo n.º 2
0
    # response.cache_control.no_store = True
    if 'cache-control' not in response.headers:
        response.headers['cache-control'] = 'no-store'
    return response


# ------ FLASK DEBUG vs. LIVE CONFIG ------
if app.config['DEBUG']:
    # live building of scss
    from sassutils.wsgi import SassMiddleware, Manifest
    app.wsgi_app = SassMiddleware(
        app.wsgi_app,
        {
            'overtrack_web': Manifest(
                '../static/scss',
                '../static/css',
                '/static/css',
                strip_extension=True,
            )
        }
    )

    # Fake login for dev
    from overtrack_web.views.fake_login import fake_login_blueprint
    app.register_blueprint(fake_login_blueprint, url_prefix='/fake_login')

    # Force js to be unminified
    orig_url_for = flask.url_for
    def url_for(endpoint, **values):
        if endpoint == 'static' and 'filename' in values and values['filename'].endswith('.min.js'):
            values['filename'] = values['filename'][:-len('.min.js')] + '.js'
        return orig_url_for(endpoint, **values)