settings.py 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. """
  2. Django settings for st_cloud project.
  3. Generated by 'django-admin startproject' using Django 3.2.7.
  4. For more information on this file, see
  5. https://docs.djangoproject.com/en/3.2/topics/settings/
  6. For the full list of settings and their values, see
  7. https://docs.djangoproject.com/en/3.2/ref/settings/
  8. """
  9. from pathlib import Path
  10. # Build paths inside the project like this: BASE_DIR / 'subdir'.
  11. BASE_DIR = Path(__file__).resolve().parent.parent
  12. MEDIA_ROOT = BASE_DIR / 'upload/'
  13. # Quick-start development settings - unsuitable for production
  14. # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
  15. # SECURITY WARNING: keep the secret key used in production secret!
  16. SECRET_KEY = 'django-insecure-h1r^p(6-s&@7u!q(sv%_@97fxv(ikbi7d9p#i9+-o_3&pbpw(j'
  17. SALT = 'sa0v-038auwmd-r0awvy4-0y4vs9mdy9-aby09384vy-amr9tv8ybsva9v4y'
  18. FILE_ENCRYPT_IV = 'fv70a9j938hvan09rh'
  19. # SECURITY WARNING: don't run with utils turned on in production!
  20. DEBUG = True
  21. ALLOWED_HOSTS = ['30gz758467.51vip.biz', '127.0.0.1']
  22. # Application definition
  23. INSTALLED_APPS = [
  24. 'django.contrib.admin',
  25. 'django.contrib.auth',
  26. 'django.contrib.contenttypes',
  27. 'django.contrib.sessions',
  28. 'django.contrib.messages',
  29. 'django.contrib.staticfiles',
  30. 'rest_framework',
  31. 'corsheaders',
  32. 'group',
  33. 'folder',
  34. 'file',
  35. 'account'
  36. ]
  37. MIDDLEWARE = [
  38. 'corsheaders.middleware.CorsMiddleware',
  39. 'django.middleware.security.SecurityMiddleware',
  40. 'django.contrib.sessions.middleware.SessionMiddleware',
  41. 'django.middleware.common.CommonMiddleware',
  42. # 'django.middleware.csrf.CsrfViewMiddleware',
  43. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  44. 'django.contrib.messages.middleware.MessageMiddleware',
  45. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  46. ]
  47. ROOT_URLCONF = 'st_cloud.urls'
  48. TEMPLATES = [
  49. {
  50. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  51. 'DIRS': [BASE_DIR / 'templates']
  52. ,
  53. 'APP_DIRS': True,
  54. 'OPTIONS': {
  55. 'context_processors': [
  56. 'django.template.context_processors.debug',
  57. 'django.template.context_processors.request',
  58. 'django.contrib.auth.context_processors.auth',
  59. 'django.contrib.messages.context_processors.messages',
  60. ],
  61. },
  62. },
  63. ]
  64. WSGI_APPLICATION = 'st_cloud.wsgi.application'
  65. # Database
  66. # https://docs.djangoproject.com/en/3.2/ref/settings/#databases
  67. DATABASES = {
  68. 'default': {
  69. 'ENGINE': 'django.db.backends.sqlite3',
  70. 'NAME': BASE_DIR / 'db.sqlite3',
  71. }
  72. }
  73. # Password validation
  74. # https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
  75. PASSWORD_RESET_TIMEOUT = 360000
  76. AUTH_PASSWORD_VALIDATORS = [
  77. {
  78. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  79. },
  80. {
  81. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  82. },
  83. {
  84. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  85. },
  86. {
  87. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  88. },
  89. ]
  90. # Internationalization
  91. # https://docs.djangoproject.com/en/3.2/topics/i18n/
  92. LANGUAGE_CODE = 'en-us'
  93. TIME_ZONE = 'UTC'
  94. USE_I18N = True
  95. USE_L10N = True
  96. USE_TZ = True
  97. # Static files (CSS, JavaScript, Images)
  98. # https://docs.djangoproject.com/en/3.2/howto/static-files/
  99. STATIC_URL = '/static/'
  100. # Default primary key field type
  101. # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
  102. DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
  103. EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
  104. EMAIL_USE_TLS = True
  105. EMAIL_HOST = 'smtp.qq.com'
  106. EMAIL_PORT = 25
  107. EMAIL_HOST_USER = 'lin-xinyuan@qq.com'
  108. EMAIL_HOST_PASSWORD = 'terwmysqpvxaeahe'
  109. DEFAULT_FROM_EMAIL = f'ST网盘 <{EMAIL_HOST_USER}>'
  110. CORS_ORIGIN_ALLOW_ALL = True
  111. CORS_ALLOW_CREDENTIALS = True
  112. # 跨域允许的请求方式,可以使用默认值,默认的请求方式为:
  113. # from corsheaders.defaults import default_methods
  114. CORS_ALLOW_METHODS = (
  115. 'GET',
  116. 'POST',
  117. 'PUT',
  118. 'PATCH',
  119. 'DELETE',
  120. 'OPTIONS'
  121. )
  122. # 允许跨域的请求头,可以使用默认值,默认的请求头为:
  123. # from corsheaders.defaults import default_headers
  124. # CORS_ALLOW_HEADERS = default_headers
  125. CORS_ALLOW_HEADERS = (
  126. 'XMLHttpRequest',
  127. 'X_FILENAME',
  128. 'accept-encoding',
  129. 'authorization',
  130. 'content-type',
  131. 'dnt',
  132. 'origin',
  133. 'user-agent',
  134. 'x-csrftoken',
  135. 'x-requested-with',
  136. 'Pragma',
  137. )
  138. # 跨域请求时,是否运行携带cookie,默认为False
  139. CORS_ALLOW_CREDENTIALS = True
  140. # 允许所有主机执行跨站点请求,默认为False
  141. # 如果没设置该参数,则必须设置白名单,运行部分白名单的主机才能执行跨站点请求
  142. CORS_ORIGIN_ALLOW_ALL = True