repos
/ status-django master

status-django

mirror archived upstream

Self-hostable uptime monitor and status page on Django: HTTP checks, Lighthouse audits, SEO crawls, and email and Discord alerts.

djangodockerhandcodedpythonself-hostedsqlitestatus-pageuptime-monitoringvite

1.7 KB · 81 lines · Python Raw History
 1import os
 2
 3from . import *  # noqa
 4
 5
 6# Custom settings
 7
 8BASE_URL = os.environ.get("DJANGO_BASE_URL")
 9
10
11# Core settings
12# https://docs.djangoproject.com/en/4.0/ref/settings/#core-settings
13
14ALLOWED_HOSTS = [os.environ.get("DJANGO_BASE_URL").split("//")[1]]
15
16
17# Debuggging
18# https://docs.djangoproject.com/en/4.0/ref/settings/#debugging
19
20DEBUG = False
21
22
23# HTTP
24# https://docs.djangoproject.com/en/4.0/ref/settings/#http
25
26SECURE_BROWSER_XSS_FILTER = True
27SECURE_HSTS_INCLUDE_SUBDOMAINS = True
28SECURE_HSTS_PRELOAD = True
29SECURE_HSTS_SECONDS = 31536000
30SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
31SECURE_SSL_REDIRECT = True
32USE_X_FORWARDED_HOST = True
33
34
35# Security
36# https://docs.djangoproject.com/en/4.0/ref/settings/#security
37
38CSRF_COOKIE_SECURE = True
39CSRF_TRUSTED_ORIGINS = [os.environ.get("DJANGO_BASE_URL")]
40SECRET_KEY = os.environ.get("DJANGO_SECRET_KEY")
41SESSION_COOKIE_SECURE = True
42
43
44# Database
45# https://docs.djangoproject.com/en/4.0/ref/settings/#databases
46
47DATABASES["default"]["NAME"] = "/data/db/db.sqlite3"
48
49
50# Email
51# https://docs.djangoproject.com/en/4.0/topics/email/#email-backends
52
53EMAIL_BACKEND = "status.mailer.DirectMXBackend"
54DEFAULT_FROM_EMAIL = "[email protected]"
55SERVER_EMAIL = "[email protected]"
56
57
58# Media files (Images, Videos)
59# https://docs.djangoproject.com/en/4.0/ref/settings/#media-root
60
61MEDIA_URL = BASE_URL + "/media/"
62MEDIA_ROOT = "/data/media"
63
64
65# Logging
66# https://docs.djangoproject.com/en/4.0/topics/logging/
67
68LOGGING = {
69    "version": 1,
70    "disable_existing_loggers": False,
71    "handlers": {
72        "console": {
73            "class": "logging.StreamHandler",
74        },
75    },
76    "root": {
77        "handlers": ["console"],
78        "level": "WARNING",
79    },
80}