settings.py 4.8 KB

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