-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathconfig.py
More file actions
40 lines (32 loc) · 1.17 KB
/
config.py
File metadata and controls
40 lines (32 loc) · 1.17 KB
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
import os
import logging
from logging.handlers import RotatingFileHandler
# Base directory of the application
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
# Directory configurations
STATIC_DIR = os.path.join(BASE_DIR, "static")
CONVERTED_DIR = os.path.join(STATIC_DIR, "converted")
LOGS_DIR = os.path.join(BASE_DIR, "logs")
# Create necessary directories
os.makedirs(STATIC_DIR, exist_ok=True)
os.makedirs(CONVERTED_DIR, exist_ok=True)
os.makedirs(LOGS_DIR, exist_ok=True)
# Logging configuration
LOG_FILE = os.path.join(LOGS_DIR, "app.log")
logging.basicConfig(
level=logging.DEBUG,
format="%(asctime)s - %(levelname)s - %(message)s"
)
handler = RotatingFileHandler(LOG_FILE, maxBytes=10000000, backupCount=5)
handler.setFormatter(logging.Formatter(
"%(asctime)s - %(levelname)s - %(message)s"
))
logger = logging.getLogger(__name__)
logger.addHandler(handler)
# Disable PIL debug logging
logging.getLogger("PIL").setLevel(logging.WARNING)
# Application configurations
class Config:
SECRET_KEY = os.environ.get('SECRET_KEY') or 'dev-key-please-change-in-production'
MAX_CONTENT_LENGTH = 16 * 1024 * 1024 # 16MB max file size
ALLOWED_EXTENSIONS = {'svg'}