mirror of
https://github.com/AudebertAdrien/ft_transcendence.git
synced 2025-12-16 05:57:48 +01:00
repare project
This commit is contained in:
parent
000e6fb5a9
commit
0e9193f98a
31
.env
Normal file
31
.env
Normal file
@ -0,0 +1,31 @@
|
||||
# Django settings
|
||||
SECRET_KEY="FollowTheWhiteRabbit"
|
||||
DEBUG=True
|
||||
DJANGO_ALLOWED_HOSTS=['*']
|
||||
|
||||
# PostgreSQL settings
|
||||
POSTGRES_DB=players_db
|
||||
POSTGRES_USER=42student
|
||||
POSTGRES_PASSWORD=qwerty
|
||||
|
||||
# Django settings
|
||||
DB_HOST=db
|
||||
DB_PORT=5432
|
||||
PWD_PATH=${PWD}
|
||||
PROJECT_PATH=${PWD_PATH}/pong
|
||||
|
||||
# ElasticSearch settings
|
||||
STACK_VERSION=8.14.3
|
||||
CLUSTER_NAME=docker-cluster
|
||||
LICENSE=basic
|
||||
|
||||
ELASTIC_USERNAME=elastic
|
||||
ELASTIC_PASSWORD=elastic_pass
|
||||
|
||||
# Kibana settings
|
||||
KIBANA_PORT=5601
|
||||
KIBANA_USERNAME=kibana_system
|
||||
KIBANA_PASSWORD=kibana_pass
|
||||
|
||||
ENCRYPTION_KEY=c34d38b3a14956121ff2170e5030b471551370178f43e5626eec58b04a30fae2
|
||||
|
||||
@ -13,7 +13,6 @@ DB_HOST=db
|
||||
DB_PORT=5432
|
||||
PWD_PATH=${PWD}
|
||||
PROJECT_PATH=${PWD_PATH}/pong
|
||||
DJANGO_LOGS=${PWD_PATH}/logs
|
||||
|
||||
# ElasticSearch settings
|
||||
STACK_VERSION=8.14.3
|
||||
@ -25,7 +24,7 @@ ELASTIC_PASSWORD=
|
||||
|
||||
# Kibana settings
|
||||
KIBANA_PORT=5601
|
||||
KIBANA_USERNAME=
|
||||
KIBANA_USERNAME=kibana_system
|
||||
KIBANA_PASSWORD=
|
||||
|
||||
ENCRYPTION_KEY=c34d38b3a14956121ff2170e5030b471551370178f43e5626eec58b04a30fae2
|
||||
|
||||
172
pong/settings.py
Normal file
172
pong/settings.py
Normal file
@ -0,0 +1,172 @@
|
||||
# /pong/settings.py
|
||||
|
||||
"""
|
||||
Django settings for pong project.
|
||||
|
||||
Generated by 'django-admin startproject' using Django 3.2.
|
||||
"""
|
||||
|
||||
import os
|
||||
import logging.config
|
||||
from pathlib import Path
|
||||
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = '12345678'
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = ['*']
|
||||
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'channels',
|
||||
'pong.game',
|
||||
'rest_framework'
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
'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',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'pong.urls'
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [os.path.join(BASE_DIR, 'pong', 'static')], # Ensure templates are found
|
||||
'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',
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
ASGI_APPLICATION = 'pong.asgi.application'
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': os.getenv('DB_NAME'),
|
||||
'USER': os.getenv('DB_USER'),
|
||||
'PASSWORD': os.getenv('DB_PASSWORD'),
|
||||
'HOST': os.getenv('DB_HOST'),
|
||||
'PORT': '5432',
|
||||
}
|
||||
}
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/3.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/3.2/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
TIME_ZONE = 'UTC'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_L10N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/3.2/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'pong/static')]
|
||||
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
|
||||
|
||||
# Default primary key field type
|
||||
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
|
||||
# Channels
|
||||
# Define the channel layers for WebSockets
|
||||
CHANNEL_LAYERS = {
|
||||
'default': {
|
||||
'BACKEND': 'channels.layers.InMemoryChannelLayer',
|
||||
},
|
||||
}
|
||||
|
||||
LOGGING = {
|
||||
'version': 1, # The version of the logging configuration schema
|
||||
'disable_existing_loggers': False, # Allows existing loggers to keep logging
|
||||
'formatters': { # Defines how log messages will be formatted
|
||||
'json': {
|
||||
'()': 'pythonjsonlogger.jsonlogger.JsonFormatter',
|
||||
# Formatter that outputs logs in JSON format, which is ideal for ingestion by Logstash.
|
||||
},
|
||||
'default': {
|
||||
'format': '[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s',
|
||||
# This is a basic text formatter with timestamp, log level, logger name, line number, and the actual message.
|
||||
},
|
||||
},
|
||||
'handlers': { # Handlers determine where the log messages are sent
|
||||
'file': {
|
||||
'level': 'INFO', # Minimum log level to be handled (INFO and above)
|
||||
'class': 'logging.FileHandler',
|
||||
'filename': os.path.join(BASE_DIR, 'logs/django.log'), # The file where logs will be saved
|
||||
'formatter': 'json', # Uses the JSON formatter defined above
|
||||
},
|
||||
'console': {
|
||||
'level': 'DEBUG', # Minimum log level to be handled (DEBUG and above)
|
||||
'class': 'logging.StreamHandler',
|
||||
'formatter': 'default', # Uses the default text formatter
|
||||
},
|
||||
},
|
||||
'loggers': { # Loggers are the actual log streams that get configured
|
||||
'django': { # The Django logger catches all messages sent by the Django framework
|
||||
'handlers': ['file', 'console'], # Sends logs to both the file and the console
|
||||
'level': 'DEBUG', # Minimum log level to be logged
|
||||
'propagate': True, # If True, messages will be passed to the parent loggers as well
|
||||
},
|
||||
},
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user