-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
108 lines (84 loc) · 3.02 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import json
import os
from app.lib.util import strtobool
class Features(object):
pass
class Base(object):
ENVIRONMENT: str = os.environ.get("ENVIRONMENT", "production")
BUILD_VERSION: str = os.environ.get("BUILD_VERSION", "")
TNA_FRONTEND_VERSION: str = ""
try:
with open(
os.path.join(
os.path.realpath(os.path.dirname(__file__)),
"node_modules/@nationalarchives/frontend",
"package.json",
)
) as package_json:
try:
data = json.load(package_json)
TNA_FRONTEND_VERSION = data["version"] or ""
except ValueError:
pass
except FileNotFoundError:
pass
SECRET_KEY: str = os.environ.get("SECRET_KEY", "")
DEBUG: bool = strtobool(os.getenv("DEBUG", "False"))
COOKIE_DOMAIN: str = os.environ.get("COOKIE_DOMAIN", "")
CSP_IMG_SRC: list[str] = os.environ.get("CSP_IMG_SRC", "'self'").split(",")
CSP_SCRIPT_SRC: list[str] = os.environ.get(
"CSP_SCRIPT_SRC", "'self'"
).split(",")
CSP_SCRIPT_SRC_ELEM: list[str] = os.environ.get(
"CSP_SCRIPT_SRC_ELEM", "'self'"
).split(",")
CSP_STYLE_SRC: list[str] = os.environ.get("CSP_STYLE_SRC", "'self'").split(
","
)
CSP_STYLE_SRC_ELEM: list[str] = os.environ.get(
"CSP_STYLE_SRC_ELEM", "'self'"
).split(",")
CSP_FONT_SRC: list[str] = os.environ.get("CSP_FONT_SRC", "'self'").split(
","
)
CSP_CONNECT_SRC: list[str] = os.environ.get(
"CSP_CONNECT_SRC", "'self'"
).split(",")
CSP_MEDIA_SRC: list[str] = os.environ.get("CSP_MEDIA_SRC", "'self'").split(
","
)
CSP_WORKER_SRC: list[str] = os.environ.get(
"CSP_WORKER_SRC", "'self'"
).split(",")
CSP_FRAME_SRC: list[str] = os.environ.get("CSP_FRAME_SRC", "'self'").split(
","
)
CSP_FEATURE_FULLSCREEN: list[str] = os.environ.get(
"CSP_FEATURE_FULLSCREEN", "'self'"
).split(",")
CSP_FEATURE_PICTURE_IN_PICTURE: list[str] = os.environ.get(
"CSP_FEATURE_PICTURE_IN_PICTURE", "'self'"
).split(",")
FORCE_HTTPS: bool = strtobool(os.getenv("FORCE_HTTPS", "True"))
CACHE_TYPE: str = "FileSystemCache"
CACHE_DEFAULT_TIMEOUT: int = int(
os.environ.get("CACHE_DEFAULT_TIMEOUT", "1")
)
CACHE_IGNORE_ERRORS: bool = True
CACHE_DIR: str = os.environ.get("CACHE_DIR", "/tmp")
GA4_ID = os.environ.get("GA4_ID", "")
class Production(Base, Features):
CACHE_DEFAULT_TIMEOUT = int(os.environ.get("CACHE_DEFAULT_TIMEOUT", "300"))
class Staging(Base, Features):
CACHE_DEFAULT_TIMEOUT = int(os.environ.get("CACHE_DEFAULT_TIMEOUT", "60"))
class Develop(Base, Features):
DEBUG = strtobool(os.getenv("DEBUG", "True"))
FORCE_HTTPS = strtobool(os.getenv("FORCE_HTTPS", "False"))
class Test(Base, Features):
ENVIRONMENT = "test"
DEBUG = True
TESTING = True
EXPLAIN_TEMPLATE_LOADING = True
CACHE_TYPE = "SimpleCache"
CACHE_DEFAULT_TIMEOUT = 1
FORCE_HTTPS = False