all repos — myprecious @ 537992b95025dee96ceaf488d003a09bdea99dc4

A lightweight web service to backup precious game saves.

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", "")
17PEPPER = os.getenv("PEPPER", "")
18
19# other constants
20MIN_PW_LENGTH = 5
21MIN_USERNAME_LENGTH = 3
22MAX_LENGTH = 20
23MISSING_COVER_URL = "https://placehold.co/100?text=no%20cover"
24BASE_DIRECTORY = "data"
25CONTENT_DIRECTORY = "content"
26MIGRATIONS_DIRECTORY = "migrations"
27MIGRATIONS_INIT_FILE = "init.sql"
28MIGRATIONS_INIT_PATH = os.path.join(MIGRATIONS_DIRECTORY, MIGRATIONS_INIT_FILE)
29DB_FILE = "myprecious.db"
30
31DB_PATH = os.path.join(BASE_DIRECTORY, DB_FILE)
32NO_GAME = {
33    "game_id": -1,
34    "platform_id": -1,
35    "title": " Click here to select a game.",
36    "cover": MISSING_COVER_URL
37}
38TOKEN_FILENAME = "igdb.txt"
39TOKEN_PATH = os.path.join(BASE_DIRECTORY, TOKEN_FILENAME)
40AUTH_URL = "https://id.twitch.tv/oauth2/token"
41AUTH_URL_PARAMS = {
42    "client_id": CLIENT_ID,
43    "client_secret": CLIENT_SECRET,
44    "grant_type": "client_credentials"
45}