all repos — myprecious @ 5acbe103e332613faff043d102cc215dc13380d2

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