settings.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. """
  2. Django settings for exam_segment_django project.
  3. Generated by 'django-admin startproject' using Django 2.1.
  4. For more information on this file, see
  5. https://docs.djangoproject.com/en/2.1/topics/settings/
  6. For the full list of settings and their values, see
  7. https://docs.djangoproject.com/en/2.1/ref/settings/
  8. """
  9. import os
  10. # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  11. BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  12. # Quick-start development settings - unsuitable for production
  13. # See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
  14. # SECURITY WARNING: keep the secret key used in production secret!
  15. SECRET_KEY = '3t_*ihwd7qfdwj0-j8t+#a48h$tw_*9gxpv9cjrvbai7h!0!1t'
  16. # SECRET_KEY = os.environ.get('DJ_SECRET_KEY')
  17. # SECURITY WARNING: don't run with debug turned on in production!
  18. DEBUG = True
  19. ALLOWED_HOSTS = ['117.50.37.71', '127.0.0.1', 'localhost',
  20. '0.0.0.0:8000', '192.168.1.208:8000', '192.168.1.208']
  21. # Application definition
  22. INSTALLED_APPS = [
  23. 'django.contrib.admin',
  24. 'django.contrib.auth',
  25. 'django.contrib.contenttypes',
  26. 'django.contrib.sessions',
  27. 'django.contrib.messages',
  28. 'django.contrib.staticfiles',
  29. 'segment.apps.SegmentConfig',
  30. ]
  31. MIDDLEWARE = [
  32. 'django.middleware.security.SecurityMiddleware',
  33. 'django.contrib.sessions.middleware.SessionMiddleware',
  34. 'django.middleware.common.CommonMiddleware',
  35. 'django.middleware.csrf.CsrfViewMiddleware',
  36. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  37. 'django.contrib.messages.middleware.MessageMiddleware',
  38. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  39. ]
  40. ROOT_URLCONF = 'exam_segment_django.urls'
  41. TEMPLATES = [
  42. {
  43. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  44. 'DIRS': [os.path.join(BASE_DIR, 'templates')],
  45. 'APP_DIRS': True,
  46. 'OPTIONS': {
  47. 'context_processors': [
  48. 'django.template.context_processors.debug',
  49. 'django.template.context_processors.request',
  50. 'django.contrib.auth.context_processors.auth',
  51. 'django.contrib.messages.context_processors.messages',
  52. ],
  53. },
  54. },
  55. ]
  56. WSGI_APPLICATION = 'exam_segment_django.wsgi.application'
  57. # Database
  58. # https://docs.djangoproject.com/en/2.1/ref/settings/#databases
  59. DATABASES = {
  60. 'default': {
  61. 'ENGINE': 'django.db.backends.sqlite3',
  62. 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
  63. }
  64. }
  65. # Password validation
  66. # https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
  67. AUTH_PASSWORD_VALIDATORS = [
  68. {
  69. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  70. },
  71. {
  72. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  73. },
  74. {
  75. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  76. },
  77. {
  78. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  79. },
  80. ]
  81. # Internationalization
  82. # https://docs.djangoproject.com/en/2.1/topics/i18n/
  83. LANGUAGE_CODE = 'en-us'
  84. TIME_ZONE = 'Asia/Shanghai'
  85. USE_I18N = True
  86. USE_L10N = True
  87. USE_TZ = False
  88. # Static files (CSS, JavaScript, Images)
  89. # https://docs.djangoproject.com/en/2.1/howto/static-files/
  90. STATIC_URL = '/static/'
  91. MEDIA_ROOT = os.path.join(BASE_DIR, 'segment', 'exam_image').replace('\\', '/')
  92. MEDIA_URL = '/exam_image/'
  93. TEMPLATES_ROOT = os.path.join(BASE_DIR, 'templates').replace('\\', '/')
  94. # segment-app settings
  95. TOLERANCE_PIX_NUMBER = 1
  96. RESIZE_RADIO = 1.0 # (0~1]
  97. OCR_BOX_URL = 'https://aip.baidubce.com/rest/2.0/ocr/v1/'
  98. OCR_URL = 'https://aip.baidubce.com/rest/2.0/ocr/v1/'
  99. # OCR_ACCURACY = 'general'
  100. OCR_ACCURACY = 'accurate'
  101. # OCR_CLIENT_ID = 'edZmhwHUTHLgrWdaxEQ72FfY'
  102. # OCR_CLIENT_SECRET = 'qcEtvS0dRygSF2Pa9KQjbMQcjPKBqGIE'
  103. OCR_CLIENT_ID = 'AVH7VGKG8QxoSotp6wG9LyZq'
  104. OCR_CLIENT_SECRET = 'gG7VYvBWLU8Rusnin8cS8Ta4dOckGFl6'
  105. OCR_TOKEN_UPDATE_DATE = 10
  106. LOGGING_TYPE = 'production'