Add working prototype
This commit is contained in:
0
config/__init__.py
Normal file
0
config/__init__.py
Normal file
132
config/settings.py
Normal file
132
config/settings.py
Normal file
@ -0,0 +1,132 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import sentry_sdk
|
||||
from dotenv import find_dotenv, load_dotenv
|
||||
from platformdirs import user_data_dir
|
||||
|
||||
load_dotenv(dotenv_path=find_dotenv(), verbose=True)
|
||||
|
||||
DATA_DIR = Path(
|
||||
user_data_dir(
|
||||
appname="TTVDrops",
|
||||
appauthor="TheLovinator",
|
||||
roaming=True,
|
||||
ensure_exists=True,
|
||||
),
|
||||
)
|
||||
|
||||
DEBUG: bool = os.getenv(key="DEBUG", default="True").lower() == "true"
|
||||
|
||||
sentry_sdk.init(
|
||||
dsn="https://35519536b56710e51cac49522b2cc29f@o4505228040339456.ingest.sentry.io/4506447308914688",
|
||||
environment="Development" if DEBUG else "Production",
|
||||
send_default_pii=True,
|
||||
traces_sample_rate=0.2,
|
||||
profiles_sample_rate=0.2,
|
||||
)
|
||||
|
||||
|
||||
BASE_DIR: Path = Path(__file__).resolve().parent.parent
|
||||
ADMINS: list[tuple[str, str]] = [("Joakim Hellsén", "tlovinator@gmail.com")]
|
||||
WSGI_APPLICATION = "config.wsgi.application"
|
||||
SECRET_KEY: str = os.getenv("DJANGO_SECRET_KEY", default="")
|
||||
TIME_ZONE = "Europe/Stockholm"
|
||||
USE_TZ = True
|
||||
LANGUAGE_CODE = "en-us"
|
||||
DECIMAL_SEPARATOR = ","
|
||||
THOUSAND_SEPARATOR = " "
|
||||
ROOT_URLCONF = "config.urls"
|
||||
STATIC_URL = "static/"
|
||||
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
||||
STATICFILES_DIRS: list[Path] = [BASE_DIR / "static"]
|
||||
STATIC_ROOT: Path = BASE_DIR / "staticfiles"
|
||||
STATIC_ROOT.mkdir(exist_ok=True)
|
||||
|
||||
if not DEBUG:
|
||||
ALLOWED_HOSTS: list[str] = ["ttvdrops.lovinator.space"]
|
||||
|
||||
EMAIL_HOST = "smtp.gmail.com"
|
||||
EMAIL_PORT = 587
|
||||
EMAIL_USE_TLS = True
|
||||
EMAIL_HOST_USER: str = os.getenv(key="EMAIL_HOST_USER", default="webmaster@localhost")
|
||||
EMAIL_HOST_PASSWORD: str = os.getenv(key="EMAIL_HOST_PASSWORD", default="")
|
||||
EMAIL_SUBJECT_PREFIX = "[TTVDrops] "
|
||||
EMAIL_USE_LOCALTIME = True
|
||||
EMAIL_TIMEOUT = 10
|
||||
DEFAULT_FROM_EMAIL: str = os.getenv(
|
||||
key="EMAIL_HOST_USER",
|
||||
default="webmaster@localhost",
|
||||
)
|
||||
SERVER_EMAIL: str = os.getenv(key="EMAIL_HOST_USER", default="webmaster@localhost")
|
||||
|
||||
INSTALLED_APPS: list[str] = [
|
||||
"core.apps.CoreConfig",
|
||||
"twitch.apps.TwitchConfig",
|
||||
"whitenoise.runserver_nostatic",
|
||||
"django.contrib.admin",
|
||||
"django.contrib.auth",
|
||||
"django.contrib.contenttypes",
|
||||
"django.contrib.sessions",
|
||||
"django.contrib.messages",
|
||||
"django.contrib.staticfiles",
|
||||
]
|
||||
|
||||
MIDDLEWARE: list[str] = [
|
||||
"django.middleware.security.SecurityMiddleware",
|
||||
"whitenoise.middleware.WhiteNoiseMiddleware",
|
||||
"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",
|
||||
]
|
||||
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
||||
"DIRS": [BASE_DIR / "templates"],
|
||||
"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",
|
||||
],
|
||||
"loaders": [
|
||||
(
|
||||
"django.template.loaders.cached.Loader",
|
||||
[
|
||||
"django.template.loaders.filesystem.Loader",
|
||||
"django.template.loaders.app_directories.Loader",
|
||||
],
|
||||
),
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
# Don't cache templates in development
|
||||
if DEBUG:
|
||||
TEMPLATES[0]["OPTIONS"]["loaders"] = [
|
||||
"django.template.loaders.filesystem.Loader",
|
||||
"django.template.loaders.app_directories.Loader",
|
||||
]
|
||||
|
||||
DATABASES = {
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.sqlite3",
|
||||
"NAME": DATA_DIR / "ttvdrops.sqlite3",
|
||||
"OPTIONS": {
|
||||
# "init_command": "PRAGMA journal_mode=wal; PRAGMA synchronous=1; PRAGMA mmap_size=134217728; PRAGMA journal_size_limit=67108864; PRAGMA cache_size=2000;", # noqa: E501
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
STORAGES: dict[str, dict[str, str]] = {
|
||||
"staticfiles": {
|
||||
"BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
|
||||
},
|
||||
}
|
10
config/urls.py
Normal file
10
config/urls.py
Normal file
@ -0,0 +1,10 @@
|
||||
from django.contrib import admin
|
||||
from django.urls import include, path
|
||||
from django.urls.resolvers import URLResolver
|
||||
|
||||
app_name: str = "config"
|
||||
|
||||
urlpatterns: list[URLResolver] = [
|
||||
path(route="admin/", view=admin.site.urls),
|
||||
path(route="", view=include(arg="core.urls")),
|
||||
]
|
8
config/wsgi.py
Normal file
8
config/wsgi.py
Normal file
@ -0,0 +1,8 @@
|
||||
import os
|
||||
|
||||
from django.core.handlers.wsgi import WSGIHandler
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault(key="DJANGO_SETTINGS_MODULE", value="config.settings")
|
||||
|
||||
application: WSGIHandler = get_wsgi_application()
|
Reference in New Issue
Block a user