123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- """
- Django settings for invoice_ocr project.
- Generated by 'django-admin startproject' using Django 3.1.4.
- For more information on this file, see
- https://docs.djangoproject.com/en/3.1/topics/settings/
- For the full list of settings and their values, see
- https://docs.djangoproject.com/en/3.1/ref/settings/
- """
- import os
- import time
- from pathlib import Path
- BASE_DIR = Path(__file__).resolve().parent.parent
- SECRET_KEY = 'l56929t$rpl&(75-g20nnoe*@q7gxp9c)i*1lh2fi=4+p-4(mj'
- DEBUG = True
- ALLOWED_HOSTS = ['119.3.54.245', '127.0.0.1']
- INSTALLED_APPS = [
- 'django.contrib.admin',
- 'django.contrib.auth',
- 'django.contrib.contenttypes',
- 'django.contrib.sessions',
- 'django.contrib.messages',
- 'django.contrib.staticfiles',
- 'corsheaders',
- 'ocr',
- ]
- MIDDLEWARE = [
- 'django.middleware.security.SecurityMiddleware',
- 'django.contrib.sessions.middleware.SessionMiddleware',
- 'corsheaders.middleware.CorsMiddleware',
- 'django.middleware.common.CommonMiddleware',
-
- 'django.contrib.auth.middleware.AuthenticationMiddleware',
- 'django.contrib.messages.middleware.MessageMiddleware',
- 'django.middleware.clickjacking.XFrameOptionsMiddleware',
- ]
- ROOT_URLCONF = 'invoice_ocr.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',
- ],
- },
- },
- ]
- WSGI_APPLICATION = 'invoice_ocr.wsgi.application'
- DATABASES = {
- 'default': {
- 'ENGINE': 'django.db.backends.sqlite3',
- 'NAME': BASE_DIR / 'db.sqlite3',
- }
- }
- 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',
- },
- ]
- LANGUAGE_CODE = 'en-us'
- TIME_ZONE = 'UTC'
- USE_I18N = True
- USE_L10N = True
- USE_TZ = True
- cur_path = os.path.dirname(os.path.realpath(__file__))
- log_path = os.path.join(os.path.dirname(cur_path), 'logs')
- if not os.path.exists(log_path):os.mkdir(log_path)
- LOGGING = {
- 'version': 1,
- 'disable_existing_loggers': True,
- 'formatters': {
-
- 'standard': {
- 'format': '[%(asctime)s] [%(filename)s:%(lineno)d] [%(module)s:%(funcName)s] '
- '[%(levelname)s]- %(message)s'},
- 'simple': {
- 'format': '%(levelname)s %(message)s'
- },
- },
-
- 'filters': {
- },
-
- 'handlers': {
-
- 'default': {
- 'level': 'INFO',
- 'class': 'logging.handlers.RotatingFileHandler',
- 'filename': os.path.join(log_path, 'all-{}.log'.format(time.strftime('%Y-%m-%d'))),
- 'maxBytes': 1024 * 1024 * 5,
- 'backupCount': 5,
- 'formatter': 'standard',
- 'encoding': 'utf-8',
- },
-
- 'error': {
- 'level': 'ERROR',
- 'class': 'logging.handlers.RotatingFileHandler',
- 'filename': os.path.join(log_path, 'error-{}.log'.format(time.strftime('%Y-%m-%d'))),
- 'maxBytes': 1024 * 1024 * 5,
- 'backupCount': 5,
- 'formatter': 'standard',
- 'encoding': 'utf-8',
- },
-
- 'console': {
- 'level': 'DEBUG',
- 'class': 'logging.StreamHandler',
- 'formatter': 'standard'
- },
-
- 'info': {
- 'level': 'INFO',
- 'class': 'logging.handlers.RotatingFileHandler',
- 'filename': os.path.join(log_path, 'info-{}.log'.format(time.strftime('%Y-%m-%d'))),
- 'maxBytes': 1024 * 1024 * 5,
- 'backupCount': 5,
- 'formatter': 'standard',
- 'encoding': 'utf-8',
- },
- },
-
- 'loggers': {
-
- 'django': {
- 'handlers': ['default', 'console'],
- 'level': 'INFO',
- 'propagate': False
- },
-
- 'log': {
- 'handlers': ['error', 'info', 'console', 'default'],
- 'level': 'INFO',
- 'propagate': True
- },
- }
- }
- CORS_ALLOW_CREDENTIALS = True
- CORS_ORIGIN_ALLOW_ALL = True
- CORS_ORIGIN_WHITELIST = (
- 'http://*.*.*.*:*',
- )
- CORS_ALLOW_METHODS = (
- 'DELETE',
- 'GET',
- 'OPTIONS',
- 'PATCH',
- 'POST',
- 'PUT',
- 'VIEW',
- )
- CORS_ALLOW_HEADERS = (
- 'XMLHttpRequest',
- 'X_FILENAME',
- 'accept-encoding',
- 'authorization',
- 'content-type',
- 'dnt',
- 'origin',
- 'user-agent',
- 'x-csrftoken',
- 'x-requested-with',
- )
- STATIC_URL = '/static/'
|