text: import os
  
  import dj_database_url
  
  # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
  
  
  # Quick-start development settings - unsuitable for production
  # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
  
  # SECURITY WARNING: keep the secret key used in production secret!
  SECRET_KEY = os.environ.get('SECRET_KEY')
  
  # SECURITY WARNING: don't run with debug turned on in production!
  DEBUG = bool(os.environ.get('DEBUG', False) in ['1', 'true', 'True'])
  
  # Application definition
  
  INSTALLED_APPS = [
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.messages',
      # Disable Django's own staticfiles handling in favour of WhiteNoise, for
      # greater consistency between gunicorn and `./manage.py runserver`. See:
      # http://whitenoise.evans.io/en/stable/django.html#using-whitenoise-in-development
      'whitenoise.runserver_nostatic',
      'django.contrib.staticfiles',
  
      'threesixty',
      'django.forms',
  ]
  
  MIDDLEWARE = [
      'django.middleware.security.SecurityMiddleware',
      'whitenoise.middleware.WhiteNoiseMiddleware',
      'django.contrib.sessions.middleware.SessionMiddleware',
      'django.middleware.common.CommonMiddleware',
      'django.middleware.csrf.CsrfViewMiddleware',
      'django.contrib.auth.middleware.AuthenticationMiddleware',
      'django.contrib.messages.middleware.MessageMiddleware',
      'django.middleware.clickjacking.XFrameOptionsMiddleware',
  ]
  
  ROOT_URLCONF = 'threesixty.urls'
  
  TEMPLATES = [
      {
          'BACKEND': 'django.template.backends.django.DjangoTemplates',
          'DIRS': [],
          'APP_DIRS': True,
          'OPTIONS': {
              'context_processors': [
                  'django.template.context_processors.debug',
                  'django.template.context_processors.request',
                  'django.contrib.auth.context_processors.auth',
                  'django.contrib.messages.context_processors.messages',
              ],
              'debug': DEBUG,
          },
      },
  ]
  
  FORM_RENDERER = 'django.forms.renderers.TemplatesSetting'
  
  WSGI_APPLICATION = 'threesixty.wsgi.application'
  
  
  # Database
  # https://docs.djangoproject.com/en/2.0/ref/settings/#databases
  
  DATABASES = {
      'default': dj_database_url.config(conn_max_age=500),
  }
  
  CSRF_COOKIE_SECURE = True
  SESSION_COOKIE_SECURE = True
  # see https://docs.djangoproject.com/en/dev/ref/middleware/#http-strict-transport-security
  SECURE_HSTS_SECONDS = 3600
  SECURE_HSTS_PRELOAD = True
  
  ATOMIC_REQUESTS = True
  
  SILENCED_SYSTEM_CHECKS = [
      "security.W005",  # HSTS for subdomains should not be set to not affect other services
  ]
  
  AUTH_PASSWORD_VALIDATORS = [
      {
          'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
      },
      {
          'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
      },
      {
          'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
      },
      {
          'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
      },
  ]
  
  # Internationalization
  # https://docs.djangoproject.com/en/2.0/topics/i18n/
  
  LANGUAGE_CODE = 'en-us'
  TIME_ZONE = 'UTC'
  USE_I18N = True
  USE_L10N = True
  USE_TZ = True
  
  # Honor the 'X-Forwarded-Proto' header for request.is_secure()
  SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
  SECURE_SSL_REDIRECT = not DEBUG
  
  if DEBUG:
      ALLOWED_HOSTS = []
  else:
      ALLOWED_HOSTS = [
          h.strip() for h in
          os.environ.get('ALLOWED_HOSTS', '').split(',')
      ]
  
  
  # Static files (CSS, JavaScript, Images)
  # https://docs.djangoproject.com/en/2.0/howto/static-files/
  
  STATIC_ROOT = os.path.join(BASE_DIR, '_static')
  STATIC_URL = '/static/'
  
  # Extra places for collectstatic to find static files.
  STATICFILES_DIRS = [
      os.path.join(PROJECT_ROOT, 'static'),
  ]
  
  # Simplified static file serving.
  # https://warehouse.python.org/project/whitenoise/
  STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
  
  
  if os.environ.get('SENDGRID_USERNAME', False) and os.environ.get('SENDGRID_PASSWORD', False):
      EMAIL_HOST = 'smtp.sendgrid.net'
      EMAIL_HOST_USER = os.environ.get('SENDGRID_USERNAME')
      EMAIL_HOST_PASSWORD = os.environ.get('SENDGRID_PASSWORD')
      EMAIL_PORT = 587
      EMAIL_USE_TLS = True
  else:
      EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
  