myprecious/Constants.py (view raw)
1from dotenv import load_dotenv
2import os, uuid
3load_dotenv()
4
5def env_bool(env_var: str):
6 return os.getenv(env_var, 'False') == 'True'
7
8# user-provided config
9DEBUG_SWITCH = env_bool("DEBUG_SWITCH")
10CLIENT_ID = os.getenv("CLIENT_ID")
11CLIENT_SECRET = os.getenv("CLIENT_SECRET")
12
13SECRET_KEY = os.getenv("SECRET_KEY", str(uuid.uuid4()))
14DEFAULT_ADMIN_USER = os.getenv("DEFAULT_ADMIN_USER", "admin")
15DEFAULT_ADMIN_PW = os.getenv("DEFAULT_ADMIN_PW", "admin")
16DEFAULT_ADMIN_EMAIL = os.getenv("DEFAULT_ADMIN_EMAIL", "")
17
18# other constants
19MIN_PW_LENGTH = 5
20MIN_USERNAME_LENGTH = 3
21MAX_LENGTH = 20
22MISSING_COVER_URL = "https://placehold.co/100?text=no%20cover"
23BASE_DIRECTORY = "data"
24CONTENT_DIRECTORY = "content"
25MIGRATIONS_DIRECTORY = "migrations"
26MIGRATIONS_INIT_FILE = "init.sql"
27MIGRATIONS_INIT_PATH = os.path.join(MIGRATIONS_DIRECTORY, MIGRATIONS_INIT_FILE)
28DB_FILE = "myprecious.db"
29
30DB_PATH = os.path.join(BASE_DIRECTORY, DB_FILE)
31NO_GAME = {
32 "game_id": -1,
33 "platform_id": -1,
34 "title": " Click here to select a game.",
35 "cover": MISSING_COVER_URL
36}
37TOKEN_FILENAME = "igdb.txt"
38TOKEN_PATH = os.path.join(BASE_DIRECTORY, TOKEN_FILENAME)
39AUTH_URL = "https://id.twitch.tv/oauth2/token"
40AUTH_URL_PARAMS = {
41 "client_id": CLIENT_ID,
42 "client_secret": CLIENT_SECRET,
43 "grant_type": "client_credentials"
44}