<commit_before>import os
import logging
import glob

from flask import Flask, g, request, session
from flask.ext.assets import Bundle
from flask_sslify import SSLify

from utils import json_markup, OrderedDictYAMLLoader
import yaml
from datetime import datetime

import config

from .site import site
from .admin import admin
from .user import User, user
from .call import call
from .campaign import campaign
from .api import api, configure_restless, restless_preprocessors
from .political_data import political_data

from extensions import cache, db, babel, assets, login_manager, csrf, mail, store, rest

DEFAULT_BLUEPRINTS = (
    site,
    admin,
    user,
    call,
    campaign,
    api,
    political_data
)


def create_app(configuration=None, app_name=None, blueprints=None):
    """Create the main Flask app."""

    if app_name is None:
        app_name = config.DefaultConfig.APP_NAME
    if blueprints is None:
        blueprints = DEFAULT_BLUEPRINTS

    app = Flask(app_name)
    # configure app from object or environment
    configure_app(app, configuration)
    SSLify(app)
    # init extensions once we have app context
    init_extensions(app)
    # then blueprints, for url/view routing
    register_blueprints(app, blueprints)

    configure_logging(app)

    # then extension specific configurations
    configure_babel(app)
    configure_login(app)
    configure_assets(app)
    configure_restless(app)

    # finally instance specific configurations
    context_processors(app)
    instance_defaults(app)

    app.logger.info('Call Power started')
    return app

<commit_msg>Flask-sslify only in production<commit_after>import os
import logging
import glob

from flask import Flask, g, request, session
from flask.ext.assets import Bundle


from utils import json_markup, OrderedDictYAMLLoader
import yaml
from datetime import datetime

import config

from .site import site
from .admin import admin
from .user import User, user
from .call import call
from .campaign import campaign
from .api import api, configure_restless, restless_preprocessors
from .political_data import political_data

from extensions import cache, db, babel, assets, login_manager, csrf, mail, store, rest

DEFAULT_BLUEPRINTS = (
    site,
    admin,
    user,
    call,
    campaign,
    api,
    political_data
)


def create_app(configuration=None, app_name=None, blueprints=None):
    """Create the main Flask app."""

    if app_name is None:
        app_name = config.DefaultConfig.APP_NAME
    if blueprints is None:
        blueprints = DEFAULT_BLUEPRINTS

    app = Flask(app_name)
    # configure app from object or environment
    configure_app(app, configuration)
    if app.config['ENVIRONMENT'] == "Production":
        from flask_sslify import SSLify
        SSLify(app)
    # init extensions once we have app context
    init_extensions(app)
    # then blueprints, for url/view routing
    register_blueprints(app, blueprints)

    configure_logging(app)

    # then extension specific configurations
    configure_babel(app)
    configure_login(app)
    configure_assets(app)
    configure_restless(app)

    # finally instance specific configurations
    context_processors(app)
    instance_defaults(app)

    app.logger.info('Call Power started')
    return app


{'fraction_non_alphanumeric': 0.06244288760280232, 'fraction_numerical': 0.0, 'mean_word_length': 3.8508124076809453, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2711814', 'n_tokens_mistral': 953, 'n_tokens_neox': 925, 'n_words': 310}