File size: 2,859 Bytes
25f22bf
 
 
 
 
 
 
 
 
 
 
 
 
b3c01df
25f22bf
 
 
 
 
 
 
 
 
 
 
b3c01df
25f22bf
 
 
 
 
 
b3c01df
25f22bf
 
b3c01df
25f22bf
 
 
b3c01df
25f22bf
 
 
 
b3c01df
25f22bf
b3c01df
 
 
25f22bf
 
b3c01df
25f22bf
 
b3c01df
25f22bf
 
 
b3c01df
25f22bf
 
b3c01df
25f22bf
 
 
b3c01df
25f22bf
 
 
 
b3c01df
25f22bf
 
 
 
b3c01df
25f22bf
 
 
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
import os
import platform
from dotenv import load_dotenv

# Load environment variables from .env file
load_dotenv()

def get_system_encoding():
    """Get the system's preferred encoding with UTF-8 fallback."""
    try:
        # Try to get the preferred encoding
        import locale
        preferred_encoding = locale.getpreferredencoding(False)

        # Ensure it's UTF-8 or a compatible encoding
        if preferred_encoding.lower() not in ['utf-8', 'utf8', 'utf_8']:
            # On Windows, try to set UTF-8
            if platform.system() == 'Windows':
                try:
                    os.environ['PYTHONIOENCODING'] = 'utf-8'
                    preferred_encoding = 'utf-8'
                except:
                    preferred_encoding = 'utf-8'
            else:
                preferred_encoding = 'utf-8'

        return preferred_encoding
    except:
        return 'utf-8'

class Config:
    """Base configuration class."""

    # Set default encoding
    DEFAULT_ENCODING = get_system_encoding()

    # Supabase configuration
    SUPABASE_URL = os.environ.get('SUPABASE_URL') or ''
    SUPABASE_KEY = os.environ.get('SUPABASE_KEY') or ''

    # LinkedIn OAuth configuration
    CLIENT_ID = os.environ.get('CLIENT_ID') or ''
    CLIENT_SECRET = os.environ.get('CLIENT_SECRET') or ''
    REDIRECT_URL = os.environ.get('REDIRECT_URL') or ''

    # Hugging Face configuration
    # Check for lowercase hugging_key first (for dev), then uppercase HUGGING_KEY (for production)
    HUGGING_KEY = os.environ.get('hugging_key') or os.environ.get('HUGGING_KEY') or ''

    # JWT configuration
    JWT_SECRET_KEY = os.environ.get('JWT_SECRET_KEY') or 'your-secret-key-change-in-production'

    # Database configuration
    DATABASE_URL = os.environ.get('DATABASE_URL') or ''

    # Application configuration
    SECRET_KEY = os.environ.get('SECRET_KEY') or 'your-secret-key-change-in-production'
    DEBUG = os.environ.get('DEBUG', 'False').lower() == 'true'

    # Scheduler configuration
    SCHEDULER_ENABLED = os.environ.get('SCHEDULER_ENABLED', 'True').lower() == 'true'

    # Unicode/Encoding configuration
    FORCE_UTF8 = os.environ.get('FORCE_UTF8', 'True').lower() == 'true'
    UNICODE_LOGGING = os.environ.get('UNICODE_LOGGING', 'True').lower() == 'true'

    # Environment detection
    ENVIRONMENT = os.environ.get('ENVIRONMENT', 'development').lower()
    IS_WINDOWS = platform.system() == 'Windows'
    IS_DOCKER = os.environ.get('DOCKER_CONTAINER', '').lower() == 'true'

    # Set environment-specific encoding settings
    if FORCE_UTF8:
        os.environ['PYTHONIOENCODING'] = 'utf-8'
        os.environ['PYTHONUTF8'] = '1'

    # Debug and logging settings
    LOG_LEVEL = os.environ.get('LOG_LEVEL', 'INFO' if ENVIRONMENT == 'production' else 'DEBUG')
    UNICODE_SAFE_LOGGING = UNICODE_LOGGING and not IS_WINDOWS