<commit_before>import os
import datetime
import environ

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
os.environ['LANG'] = 'en_US.UTF-8'

env = environ.Env(
    DEBUG=(bool, False),
    ALLOWED_HOSTS=(list, []),
    COMPRESS_ENABLED=(bool, False),
    EMAIL_HOST=(str, ''),
    EMAIL_PORT=(int, 587),
    EMAIL_HOST_USER=(str, ''),
    EMAIL_HOST_PASSWORD=(str, ''),
    CACHE_LOCATION=(str, None),
    GOOGLE_API_KEY=(str, None),
    RECAPTCHA_PUBLIC_KEY=(str, None),
    RECAPTCHA_PRIVATE_KEY=(str, None),
    SUMMONERS_WAR_SECRET_KEY=(str, ''),
    BUGSNAG_API_KEY=(str, None),
)
environ.Env.read_env(os.path.join(BASE_DIR, '.env'))

SITE_ID = 1
SECRET_KEY = env('SECRET_KEY')
SUMMONERS_WAR_SECRET_KEY = env('SUMMONERS_WAR_SECRET_KEY')
DEBUG = env('DEBUG')
WSGI_APPLICATION = 'swarfarm.wsgi.application'

# Security settings
ALLOWED_HOSTS = env('ALLOWED_HOSTS')
INTERNAL_IPS = ['127.0.0.1', '10.0.2.2']

if DEBUG:
    ALLOWED_HOSTS += ['10.0.2.2', '10.243.243.10']

PASSWORD_HASHERS = (
    'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
    'django.contrib.auth.hashers.BCryptPasswordHasher',
    'django.contrib.auth.hashers.PBKDF2PasswordHasher',
    'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
    'django.contrib.auth.hashers.SHA1PasswordHasher',
    'django.contrib.auth.hashers.MD5PasswordHasher',
    'django.contrib.auth.hashers.CryptPasswordHasher',
)

# SSL settings
SECURE_SSL_REDIRECT = not DEBUG
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
CSRF_COOKIE_SECURE = not DEBUG
CSRF_COOKIE_HTTPONLY = not DEBUG
SESSION_COOKIE_SECURE = not DEBUG
X_FRAME_OPTIONS = 'DENY'
SECURE_CONTENT_TYPE_NOSNIFF = not DEBUG
SECURE_BROWSER_XSS_FILTER = not DEBUG
SECURE_HSTS_SECONDS = 31556926  # 1 year
SECURE_HSTS_INCLUDE_SUBDOMAINS = not DEBUG
SECURE_HSTS_PRELOAD = not DEBUG

# Email settings
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = env('EMAIL_HOST')
EMAIL_PORT = env('EMAIL_PORT')
EMAIL_HOST_USER = env('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = env('EMAIL_HOST_PASSWORD')
EMAIL_USE_TLS = True
SERVER_EMAIL = '<EMAIL>'
DEFAULT_FROM_EMAIL = SERVER_EMAIL

# Admins and Managers
ADMINS = (('Peter', '<EMAIL>'),)
MANAGERS = ADMINS

# Application definition
INSTALLED_APPS = [
    # Packages
    'suit',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.flatpages',
    'django.contrib.humanize',
    'django.contrib.messages',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.staticfiles',
    'dal',
    'dal_select2',
    'django_filters',
    'captcha',
    'compressor',
    'corsheaders',
    'crispy_forms',
    'django_celery_results',
    'django_celery_beat',
    'markdown_deux',
    'rest_framework',
    'refreshtoken',
    'rest_framework_swagger',
    'timezone_field',

    # Custom apps
    'api',
    'apiv2',
    'herders',
    'bestiary',
    'news',
    'feedback',
    'sw_parser',
]

if DEBUG:
    INSTALLED_APPS += [
        'debug_toolbar',
    ]

MIDDLEWARE = [
    'django.contrib.sessions.middleware.SessionMiddleware',
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
]

if DEBUG:
    MIDDLEWARE = ['debug_toolbar.middleware.DebugToolbarMiddleware'] + MIDDLEWARE

# Bugsnag
if env('BUGSNAG_API_KEY'):<commit_msg>Added Django redirect module<commit_after>import os
import datetime
import environ

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
os.environ['LANG'] = 'en_US.UTF-8'

env = environ.Env(
    DEBUG=(bool, False),
    ALLOWED_HOSTS=(list, []),
    COMPRESS_ENABLED=(bool, False),
    EMAIL_HOST=(str, ''),
    EMAIL_PORT=(int, 587),
    EMAIL_HOST_USER=(str, ''),
    EMAIL_HOST_PASSWORD=(str, ''),
    CACHE_LOCATION=(str, None),
    GOOGLE_API_KEY=(str, None),
    RECAPTCHA_PUBLIC_KEY=(str, None),
    RECAPTCHA_PRIVATE_KEY=(str, None),
    SUMMONERS_WAR_SECRET_KEY=(str, ''),
    BUGSNAG_API_KEY=(str, None),
)
environ.Env.read_env(os.path.join(BASE_DIR, '.env'))

SITE_ID = 1
SECRET_KEY = env('SECRET_KEY')
SUMMONERS_WAR_SECRET_KEY = env('SUMMONERS_WAR_SECRET_KEY')
DEBUG = env('DEBUG')
WSGI_APPLICATION = 'swarfarm.wsgi.application'

# Security settings
ALLOWED_HOSTS = env('ALLOWED_HOSTS')
INTERNAL_IPS = ['127.0.0.1', '10.0.2.2']

if DEBUG:
    ALLOWED_HOSTS += ['10.0.2.2', '10.243.243.10']

PASSWORD_HASHERS = (
    'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
    'django.contrib.auth.hashers.BCryptPasswordHasher',
    'django.contrib.auth.hashers.PBKDF2PasswordHasher',
    'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
    'django.contrib.auth.hashers.SHA1PasswordHasher',
    'django.contrib.auth.hashers.MD5PasswordHasher',
    'django.contrib.auth.hashers.CryptPasswordHasher',
)

# SSL settings
SECURE_SSL_REDIRECT = not DEBUG
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
CSRF_COOKIE_SECURE = not DEBUG
CSRF_COOKIE_HTTPONLY = not DEBUG
SESSION_COOKIE_SECURE = not DEBUG
X_FRAME_OPTIONS = 'DENY'
SECURE_CONTENT_TYPE_NOSNIFF = not DEBUG
SECURE_BROWSER_XSS_FILTER = not DEBUG
SECURE_HSTS_SECONDS = 31556926  # 1 year
SECURE_HSTS_INCLUDE_SUBDOMAINS = not DEBUG
SECURE_HSTS_PRELOAD = not DEBUG

# Email settings
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = env('EMAIL_HOST')
EMAIL_PORT = env('EMAIL_PORT')
EMAIL_HOST_USER = env('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = env('EMAIL_HOST_PASSWORD')
EMAIL_USE_TLS = True
SERVER_EMAIL = '<EMAIL>'
DEFAULT_FROM_EMAIL = SERVER_EMAIL

# Admins and Managers
ADMINS = (('Peter', '<EMAIL>'),)
MANAGERS = ADMINS

# Application definition
INSTALLED_APPS = [
    # Packages
    'suit',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.flatpages',
    'django.contrib.humanize',
    'django.contrib.messages',
    'django.contrib.redirects',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.staticfiles',
    'dal',
    'dal_select2',
    'django_filters',
    'captcha',
    'compressor',
    'corsheaders',
    'crispy_forms',
    'django_celery_results',
    'django_celery_beat',
    'markdown_deux',
    'rest_framework',
    'refreshtoken',
    'rest_framework_swagger',
    'timezone_field',

    # Custom apps
    'api',
    'apiv2',
    'herders',
    'bestiary',
    'news',
    'feedback',
    'sw_parser',
]

if DEBUG:
    INSTALLED_APPS += [
        'debug_toolbar',
    ]

MIDDLEWARE = [
    'django.contrib.sessions.middleware.SessionMiddleware',
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
    'django.contrib.redirects.middleware.RedirectFallbackMiddleware',
]

if DEBUG:
    MIDDLEWARE = ['debug_toolbar.middleware.DebugToolbarMiddleware'] + MIDDLEWARE

# Bugsnag
if env('BUGSNAG_API_KEY'):
{'fraction_non_alphanumeric': 0.1327628678853883, 'fraction_numerical': 0.012965123816932453, 'mean_word_length': 4.808734939759036, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 8, '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': '3473766', 'n_tokens_mistral': 2915, 'n_tokens_neox': 2860, 'n_words': 376}