-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.py
More file actions
37 lines (27 loc) · 1 KB
/
config.py
File metadata and controls
37 lines (27 loc) · 1 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
import os
class Config:
"""Base configuration"""
SECRET_KEY = os.getenv("SECRET_KEY", "your_default_secret_key")
SQLALCHEMY_TRACK_MODIFICATIONS = False
# File Upload Configurations
UPLOAD_FOLDER = "static/images"
ALLOWED_EXTENSIONS = {"png", "jpg", "jpeg", "gif"}
# Ensure the upload directory exists
os.makedirs(UPLOAD_FOLDER, exist_ok=True)
@staticmethod
def allowed_file(filename):
"""Check if the uploaded file is allowed."""
return "." in filename and filename.rsplit(".", 1)[1].lower() in Config.ALLOWED_EXTENSIONS
class DevelopmentConfig(Config):
"""Development configuration"""
DEBUG = True
SQLALCHEMY_DATABASE_URI = "sqlite:///furniture.db"
class ProductionConfig(Config):
"""Production configuration"""
DEBUG = False
SQLALCHEMY_DATABASE_URI = os.getenv("DATABASE_URL", "sqlite:///furniture.db")
# Dictionary to easily switch environments
config_dict = {
"development": DevelopmentConfig,
"production": ProductionConfig
}