text: """
  Django settings for CTF_AWD_Platform project.
  
  Generated by 'django-admin startproject' using Django 2.2.
  
  For more information on this file, see
  https://docs.djangoproject.com/en/2.2/topics/settings/
  
  For the full list of settings and their values, see
  https://docs.djangoproject.com/en/2.2/ref/settings/
  """
  
  import os
  import sys
  import datetime
  
  # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  
  sys.path.insert(0,os.path.join(BASE_DIR,'apps'))  #二级目录app
  sys.path.insert(0,os.path.join(BASE_DIR,'extra_apps'))  #二级目录app
  
  # Quick-start development settings - unsuitable for production
  # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
  
  # SECURITY WARNING: keep the secret key used in production secret!
  SECRET_KEY = '03tt2_6@txd9v1f7yj*@8f$l9^#h_j9si4tf*a-ctkinrsz77@'
  
  # SECURITY WARNING: don't run with debug turned on in production!
  DEBUG = True
  
  
  #设置允许任何ip访问
  ALLOWED_HOSTS = ["*"]
  
  
  # Application definition
  
  
  
  
  INSTALLED_APPS = [
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.messages',
      'django.contrib.staticfiles',
      'rest_framework',
      'xadmin',
      'crispy_forms',
      'users.apps.UsersConfig',
      'teams.apps.TeamsConfig',
      'competition.apps.CompetitionConfig',
      'ctf.apps.CtfConfig',
      'info.apps.InfoConfig',
      'choice.apps.ChoiceConfig',
      'notice.apps.NoticeConfig',
      'django_filters',
      'corsheaders',
      'import_export',
  
  ]
  
  
  
  MIDDLEWARE = [
      'corsheaders.middleware.CorsMiddleware',
      'django.middleware.security.SecurityMiddleware',
      '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',
  ]
  
  CORS_ORIGIN_ALLOW_ALL = True
  
  ROOT_URLCONF = 'CTF_AWD_Platform.urls'
  
  TEMPLATES = [
      {
          'BACKEND': 'django.template.backends.django.DjangoTemplates',
          'DIRS': [os.path.join(BASE_DIR, 'templates')]
          ,
          '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',
              ],
          },
      },
  ]
  
  WSGI_APPLICATION = 'CTF_AWD_Platform.wsgi.application'
  
  
  # Database
  # https://docs.djangoproject.com/en/2.2/ref/settings/#databases
  
  DATABASES = {
      'default': {
          # 'ENGINE': 'django.db.backends.sqlite3',
          # 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
          'ENGINE': 'django.db.backends.mysql',
          'NAME': 'ctf',
          'USER': 'root',
          'PASSWORD': 'SDUTctf123.',
          'HOST': '10.6.65.231',
          'PORT': '3306',
          'TEST': {
                  'CHARSET': 'utf8',
                  'COLLATION': 'utf8_general_ci',
              }
  
      },
  
  }
  
  
  # Password validation
  # https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
  
  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.2/topics/i18n/
  
  LANGUAGE_CODE = 'zh-hans'
  
  TIME_ZONE = 'Asia/Shanghai'
  
  USE_I18N = True
  
  USE_L10N = True
  
  USE_TZ = False
  
  
  # Static files (CSS, JavaScript, Images)
  # https://docs.djangoproject.com/en/2.2/howto/static-files/
  
  STATIC_URL = '/static/'
  
  
  
  ## 重写user
  
  AUTH_USER_MODEL = 'users.UserProfile'
  
  ## media路径
  MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
  MEDIA_URL = '/media/'
  
  
  ## DRF config
  from rest_framework_jwt.authentication import JSONWebTokenAuthentication
  REST_FRAMEWORK = {
      'DEFAULT_FILTER_BACKENDS': ('django_filters.rest_framework.DjangoFilterBackend',),
      'DEFAULT_PERMISSION_CLASSES': (
          # 'rest_framework.permissions.IsAuthenticated',  # 允许认证用户
      ),
  
      'JWT_PAYLOAD_HANDLER':'rest_framework_jwt.utils.jwt_payload_handler',
  
      'DEFAULT_AUTHENTICATION_CLASSES': (
          # 'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
          # 'rest_framework.authentication.SessionAuthentication',    #sessionid验证方式
          # 'rest_framework.authentication.BasicAuthentication',  #账号密码验证方式
      ),
      'DEFAULT_THROTTLE_CLASSES': (
          'rest_framework.throttling.ScopedRateThrottle',
      ),
      'DEFAULT_THROTTLE_RATES': {
          'CtfSubmit': '12/min',
          'uploads': '20/day'
      }
  }
  
  
  
  AUTHENTICATION_BACKENDS = (
      'utils.CustomBackend.UserCustomBackend',
  )
  
  ## JWT conf
  
  ## :TODO： 字段设置失效，直接修改源代码
  
  JWT_AUTH = {
      'JWT_EXPIRATION_DELTA': datetime.timedelta(hours=3),   #有效期180分钟
      #定义与令牌一起发送的Authorization标头值前缀
      'JWT_AUTH_HEADER_PREFIX': 'SDUT',
      'JWT_AUTH_COOKIE': None,
      'JWT_ALGORITHM': 'HS256',
      'JWT_ALLOW_REFRESH': True,   #允许刷新
      'JWT_REFRESH_EXPIRATION_DELTA': datetime.timedelta(days=7),
  
  }
  
  ## 容联云通讯平台
  # ACCOUNT_SID = '8a216da86a2a8174016a39f0748d09ec'
  # AUTH_TOKEN = 'dd49474506d14a07b5acffdf0468c44f'
  
  
  # 手机号码正则表达式
  REGEX_MOBILE = "^1[358]\d{9}$|^147\d{8}$|^176\d{8}$"
  #邮箱正则表达式
  REGEX_EMAIL = "^[a-z0-9A-Z]+[- | a-z0-9A-Z . _]+@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-z]{2,}$"
  
  
  #Cache缓存配置
  REST_FRAMEWORK_EXTENSIONS = {
      'DEFAULT_CACHE_RESPONSE_TIMEOUT': 60*5, #五分钟
      'DEFAULT_USE_CACHE': 'default',  #缓存的存储方式，与配置文件中的CACHES的键对应。
  }
  
  
  # Redis作为Cache配置
  CACHES = {
      "default": {
          "BACKEND": "django_redis.cache.RedisCache",
          "LOCATION": "redis://:SDUTctf@10.6.65.231:6379/1",
          "OPTIONS": {
              "CLIENT_CLASS": "django_redis.client.DefaultClient",
          }
      }
  }
  
  
  # 配置sentry
  import sentry_sdk
  from sentry_sdk.integrations.django import DjangoIntegration
  
  sentry_sdk.init(
      dsn="http://cba487c614b843a5a35aea062d13e96b:2c848533b72747efa7f26504f64fd08e@10.6.65.231:9000/3",
      integrations=[DjangoIntegration()]
  )
  
  
  
  # 163邮箱配置
  
  EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
  EMAIL_HOST = 'smtp.163.com'
  EMAIL_PORT = 25
  #发送邮件的邮箱
  EMAIL_HOST_USER = '15615833854@163.com'
  #客户端授权密码
  EMAIL_HOST_PASSWORD = 'sdutseclab507'
  #收件人看到的发件人信息
  EMAIL_FROM = 'SDUTCTF2019<15615833854@163.com>'
  EMAIL_USE_TLS = False
  
  
  