Rythuai / config.py
bharath1108's picture
Create config.py
25fc2cb verified
import os
from datetime import timedelta
class Config:
"""Base configuration"""
# Flask
SECRET_KEY = os.environ.get('SECRET_KEY') or os.urandom(24)
# File Upload
UPLOAD_FOLDER = 'static/uploads/'
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'webp'}
MAX_CONTENT_LENGTH = 16 * 1024 * 1024 # 16 MB
# Session
PERMANENT_SESSION_LIFETIME = timedelta(hours=1)
SESSION_COOKIE_SECURE = False
SESSION_COOKIE_HTTPONLY = True
SESSION_COOKIE_SAMESITE = 'Lax'
# Model
MODEL_NAME = "wambugu71/crop_leaf_diseases_vit"
# Logging
LOG_LEVEL = 'INFO'
class DevelopmentConfig(Config):
"""Development configuration"""
DEBUG = True
TESTING = False
class ProductionConfig(Config):
"""Production configuration"""
DEBUG = False
TESTING = False
SESSION_COOKIE_SECURE = True
# Rate limiting
RATELIMIT_ENABLED = True
RATELIMIT_DEFAULT = "100 per hour"
# Security headers
TALISMAN_FORCE_HTTPS = False # Set to True if using HTTPS
class TestingConfig(Config):
"""Testing configuration"""
DEBUG = True
TESTING = True
# Configuration dictionary
config = {
'development': DevelopmentConfig,
'production': ProductionConfig,
'testing': TestingConfig,
'default': DevelopmentConfig
}
def get_config(env=None):
"""Get configuration based on environment"""
if env is None:
env = os.environ.get('FLASK_ENV', 'development')
return config.get(env, config['default'])